-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSPIRVTargetMachine.cpp
More file actions
86 lines (72 loc) · 3.53 KB
/
SPIRVTargetMachine.cpp
File metadata and controls
86 lines (72 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//===-- SPIRCTargetMachine.cpp - Define TargetMachine for SPIRV -----------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//
//===----------------------------------------------------------------------===//
#include "SPIRVTargetMachine.h"
#include "SPIRVWriterPass.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/Support/TargetRegistry.h"
using namespace llvm;
/// Create an ILP32 architecture model
SPIRVTargetMachine::SPIRVTargetMachine(const Target &T, StringRef _DL,
const Triple &TT,
StringRef CPU, StringRef FS,
const TargetOptions &Options,
SPIRVTargetMachineType stmt,
Reloc::Model RM,
CodeModel::Model CM, CodeGenOpt::Level OL,
bool Jit)
: LLVMTargetMachine(T, _DL, TT, CPU, FS, Options,RM,CM,OL), stmt(stmt) {
}
SPIRVTargetMachine::~SPIRVTargetMachine() {}
bool SPIRVTargetMachine::addPassesToEmitFile(PassManagerBase &PM, raw_pwrite_stream &Out,
raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
bool DisableVerify, MachineModuleInfo* MMI)
{
PM.add(createSPIRVWriterPass(Out));
return false;
}
SPIRV32TargetMachine::SPIRV32TargetMachine(const Target &T, const Triple &TT,
StringRef CPU, StringRef FS,
const TargetOptions &_Options, Optional<Reloc::Model> RM,
Optional<CodeModel::Model> CM, CodeGenOpt::Level OL, bool Jit)
: SPIRVTargetMachine(T,SPIR_DATALAYOUT32,TT,CPU,FS,_Options,STMT_OCL32,
Reloc::Static,
CM ? *CM : CodeModel::Medium,
OL,false) {}
SPIRV64TargetMachine::SPIRV64TargetMachine(const Target &T, const Triple &TT,
StringRef CPU, StringRef FS,
const TargetOptions &_Options,Optional<Reloc::Model> RM,
Optional<CodeModel::Model> CM, CodeGenOpt::Level OL, bool Jit)
: SPIRVTargetMachine(T,SPIR_DATALAYOUT64,TT,CPU,FS,_Options,STMT_OCL64,
Reloc::Static,
CM ? *CM : CodeModel::Medium,
OL, false) {}
SPIRVLTargetMachine::SPIRVLTargetMachine(const Target &T, const Triple &TT,
StringRef CPU, StringRef FS,
const TargetOptions &_Options,Optional<Reloc::Model> RM,
Optional<CodeModel::Model> CM, CodeGenOpt::Level OL, bool Jit)
// TODO: data layout
: SPIRVTargetMachine(T,"",TT,CPU,FS,_Options,STMT_VK,Reloc::Static,
CM ? *CM : CodeModel::Medium,
OL, false) {}
namespace llvm {
Target &getTheSPIRV32Target();
Target &getTheSPIRV64Target();
//Target &getTheSPIRVLTarget();
}
extern "C" void LLVMInitializeSPIRVTarget() {
// Register the target.
RegisterTargetMachine<SPIRV32TargetMachine> X(getTheSPIRV32Target());
RegisterTargetMachine<SPIRV64TargetMachine> Y(getTheSPIRV64Target());
//RegisterTargetMachine<SPIRVLTargetMachine> Z(getTheSPIRVLTarget());
}