Преглед изворни кода

[SPIR] Simplified target checking.

Switched to Triple::isSPIR() helper to simplify code.

Patch by kpet (Kevin Petit)!

Differential revision: https://reviews.llvm.org/D61639



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360325 91177308-0d34-0410-b5e6-96231b3b80d8
Anastasia Stulova пре 6 година
родитељ
комит
cd7db9f83f

+ 1 - 2
lib/CodeGen/CodeGenModule.cpp

@@ -539,8 +539,7 @@ void CodeGenModule::Release() {
   if (LangOpts.OpenCL) {
     EmitOpenCLMetadata();
     // Emit SPIR version.
-    if (getTriple().getArch() == llvm::Triple::spir ||
-        getTriple().getArch() == llvm::Triple::spir64) {
+    if (getTriple().isSPIR()) {
       // SPIR v2.0 s2.12 - The SPIR version used by the module is stored in the
       // opencl.spir.version named metadata.
       llvm::Metadata *SPIRVerElts[] = {

+ 1 - 3
lib/Frontend/CompilerInvocation.cpp

@@ -3349,10 +3349,8 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
                               Res.getFrontendOpts().ProgramAction);
 
   // Turn on -Wspir-compat for SPIR target.
-  auto Arch = T.getArch();
-  if (Arch == llvm::Triple::spir || Arch == llvm::Triple::spir64) {
+  if (T.isSPIR())
     Res.getDiagnosticOpts().Warnings.push_back("spir-compat");
-  }
 
   // If sanitizer is enabled, disable OPT_ffine_grained_bitfield_accesses.
   if (Res.getCodeGenOpts().FineGrainedBitfieldAccesses &&

+ 1 - 2
lib/Frontend/InitPreprocessor.cpp

@@ -1072,8 +1072,7 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
     Builder.defineMacro(#Ext);
 #include "clang/Basic/OpenCLExtensions.def"
 
-    auto Arch = TI.getTriple().getArch();
-    if (Arch == llvm::Triple::spir || Arch == llvm::Triple::spir64)
+    if (TI.getTriple().isSPIR())
       Builder.defineMacro("__IMAGE_SUPPORT__");
   }