@@ -19,25 +19,14 @@ namespace llvm {
19
19
using namespace llvm ;
20
20
using namespace SPIRV ;
21
21
22
- // TODO: The LLVM SPIR-V backend API has changed in
23
- // https://github.com/llvm/llvm-project/pull/124745 to improve the way SPIR-V
24
- // Backend API works with user facing options and allow for multithreading
25
- // within the host application. This PR in llvm-project breaks existing API
26
- // contract in how options are being interpreted inside the call, and we need to
27
- // update this file accordingly. After this change is visible in the LLVM
28
- // version from cmake/llvm-hash.txt we will need to update the call to
29
- // SPIRVTranslateModule(M, Result, ErrMsg, AllowExtNames, Opts) in a style of
30
- // SPIRVTranslate(M, Result, ErrMsg, {"all"}, CodeGenOptLevel::Aggressive,
31
- // Triple("spirv64v1.6-unknown-unknown")).
32
-
33
22
// The LLVM SPIR-V backend exposes an API call that translates LLVM module to
34
23
// SPIR-V and writes results into a string as binary SPIR-V output, providing
35
- // diagnostics on fail and means of configuring translation
36
- // (https://github.com/llvm/llvm-project/pull/107216).
37
- extern " C " bool
38
- SPIRVTranslateModule (Module *M, std::string &SpirvObj, std::string &ErrMsg ,
39
- const std::vector<std::string> &AllowExtNames ,
40
- const std::vector<std::string> &Opts );
24
+ // diagnostics on fail and means of configuring translation.
25
+ extern " C " bool SPIRVTranslate (Module *M, std::string &SpirvObj,
26
+ std::string &ErrMsg,
27
+ const std::vector< std::string> &AllowExtNames ,
28
+ llvm::CodeGenOptLevel OLevel ,
29
+ Triple TargetTriple );
41
30
42
31
static inline Triple::SubArchType
43
32
spirvVersionToSubArch (SPIRV::VersionNumber VN) {
@@ -63,10 +52,7 @@ spirvVersionToSubArch(SPIRV::VersionNumber VN) {
63
52
bool runSpirvBackend (Module *M, std::string &Result, std::string &ErrMsg,
64
53
const SPIRV::TranslatorOpts &TranslatorOpts) {
65
54
static const std::string DefaultTriple = " spirv64v1.6-unknown-unknown" ;
66
- static const std::vector<std::string> Opts{
67
- " --avoid-spirv-capabilities" , " Shader" , " --translator-compatibility-mode" ,
68
- " --spirv-ext=all" , " -spirv-O3" };
69
- static const std::vector<std::string> AllowExtNames;
55
+ static const std::vector<std::string> AllowExtNames{" all" };
70
56
71
57
// Correct the Triple value if needed
72
58
Triple TargetTriple (M->getTargetTriple ());
@@ -79,16 +65,17 @@ bool runSpirvBackend(Module *M, std::string &Result, std::string &ErrMsg,
79
65
// We need to reset Data Layout to conform with the TargetMachine
80
66
M->setDataLayout (" " );
81
67
}
68
+ if (TargetTriple.getTriple ().empty ())
69
+ TargetTriple.setTriple (DefaultTriple);
82
70
if (TranslatorOpts.getMaxVersion () != VersionNumber::MaximumVersion) {
83
- if (TargetTriple.getTriple ().empty ())
84
- TargetTriple.setTriple (DefaultTriple);
85
71
TargetTriple.setArch (TargetTriple.getArch (),
86
72
spirvVersionToSubArch (TranslatorOpts.getMaxVersion ()));
87
73
M->setTargetTriple (TargetTriple.str ());
88
74
}
89
75
90
76
// Translate the Module into SPIR-V
91
- return SPIRVTranslateModule (M, Result, ErrMsg, AllowExtNames, Opts);
77
+ return SPIRVTranslate (M, Result, ErrMsg, AllowExtNames,
78
+ CodeGenOptLevel::Aggressive, TargetTriple);
92
79
}
93
80
94
81
bool runSpirvBackend (Module *M, std::ostream &OS, std::string &ErrMsg,
0 commit comments