Proteus
Programmable JIT compilation and optimization for C/C++ using LLVM
Loading...
Searching...
No Matches
TargetModel.hpp
Go to the documentation of this file.
1#ifndef PROTEUS_TARGET_MODE_H
2#define PROTEUS_TARGET_MODE_H
3
4#include <llvm/ADT/StringRef.h>
5#include <llvm/TargetParser/Host.h>
6#include <llvm/TargetParser/Triple.h>
7
8#include "proteus/Error.h"
9
10namespace proteus {
11
12using namespace llvm;
13
15
17 if (Target == "host" || Target == "native") {
19 }
20
21 if (Target == "cuda") {
23 }
24
25 if (Target == "hip") {
27 }
28
29 if (Target == "host_hip") {
31 }
32
33 if (Target == "host_cuda") {
35 }
36
37 PROTEUS_FATAL_ERROR("Unsupported target " + Target);
38}
39
41 switch (Model) {
45 return sys::getProcessTriple();
47 return "nvptx64-nvidia-cuda";
49 return "amdgcn-amd-amdhsa";
50 default:
51 PROTEUS_FATAL_ERROR("Unsupported target model");
52 }
53}
54
55inline bool isHostTargetModel(TargetModelType TargetModel) {
56 return (TargetModel == TargetModelType::HOST) ||
57 (TargetModel == TargetModelType::HOST_HIP) ||
58 (TargetModel == TargetModelType::HOST_CUDA);
59}
60
61} // namespace proteus
62
63#endif
#define PROTEUS_FATAL_ERROR(x)
Definition Error.h:7
Definition Helpers.h:138
Definition BuiltinsCUDA.cpp:4
TargetModelType
Definition TargetModel.hpp:14
bool isHostTargetModel(TargetModelType TargetModel)
Definition TargetModel.hpp:55
T getRuntimeConstantValue(void *Arg)
Definition CompilerInterfaceRuntimeConstantInfo.h:114
TargetModelType parseTargetModel(StringRef Target)
Definition TargetModel.hpp:16
std::string getTargetTriple(TargetModelType Model)
Definition TargetModel.hpp:40