[llvm] r245115 - Add a target environment for CoreCLR.

Pat Gavlin via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 14 15:41:44 PDT 2015


Author: pgavlin
Date: Fri Aug 14 17:41:43 2015
New Revision: 245115

URL: http://llvm.org/viewvc/llvm-project?rev=245115&view=rev
Log:
Add a target environment for CoreCLR.

Although targeting CoreCLR is similar to targeting MSVC, there are
certain important differences that the backend must be aware of
(e.g. differences in stack probes, EH, and library calls).

Differential Revision: http://reviews.llvm.org/D11012

Modified:
    llvm/trunk/include/llvm/ADT/Triple.h
    llvm/trunk/lib/Support/Triple.cpp
    llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
    llvm/trunk/lib/Target/X86/X86Subtarget.h
    llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
    llvm/trunk/test/CodeGen/WinEH/seh-catch-all.ll
    llvm/trunk/test/CodeGen/WinEH/seh-inlined-finally.ll
    llvm/trunk/test/CodeGen/WinEH/seh-outlined-finally.ll
    llvm/trunk/test/CodeGen/WinEH/seh-prepared-basic.ll
    llvm/trunk/test/CodeGen/WinEH/seh-resume-phi.ll
    llvm/trunk/test/CodeGen/WinEH/seh-simple.ll
    llvm/trunk/test/CodeGen/X86/stack-probe-size.ll

Modified: llvm/trunk/include/llvm/ADT/Triple.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=245115&r1=245114&r2=245115&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/Triple.h (original)
+++ llvm/trunk/include/llvm/ADT/Triple.h Fri Aug 14 17:41:43 2015
@@ -171,7 +171,8 @@ public:
     Itanium,
     Cygnus,
     AMDOpenCL,
-    LastEnvironmentType = AMDOpenCL
+    CoreCLR,
+    LastEnvironmentType = CoreCLR
   };
   enum ObjectFormatType {
     UnknownObjectFormat,
@@ -438,6 +439,10 @@ public:
     return getOS() == Triple::Win32 && getEnvironment() == Triple::MSVC;
   }
 
+  bool isWindowsCoreCLREnvironment() const {
+    return getOS() == Triple::Win32 && getEnvironment() == Triple::CoreCLR;
+  }
+
   bool isWindowsItaniumEnvironment() const {
     return getOS() == Triple::Win32 && getEnvironment() == Triple::Itanium;
   }

Modified: llvm/trunk/lib/Support/Triple.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=245115&r1=245114&r2=245115&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Triple.cpp (original)
+++ llvm/trunk/lib/Support/Triple.cpp Fri Aug 14 17:41:43 2015
@@ -197,6 +197,7 @@ const char *Triple::getEnvironmentTypeNa
   case Itanium: return "itanium";
   case Cygnus: return "cygnus";
   case AMDOpenCL: return "amdopencl";
+  case CoreCLR: return "coreclr";
   }
 
   llvm_unreachable("Invalid EnvironmentType!");
@@ -432,6 +433,7 @@ static Triple::EnvironmentType parseEnvi
     .StartsWith("itanium", Triple::Itanium)
     .StartsWith("cygnus", Triple::Cygnus)
     .StartsWith("amdopencl", Triple::AMDOpenCL)
+    .StartsWith("coreclr", Triple::CoreCLR)
     .Default(Triple::UnknownEnvironment);
 }
 

Modified: llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp?rev=245115&r1=245114&r2=245115&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp (original)
+++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp Fri Aug 14 17:41:43 2015
@@ -122,7 +122,8 @@ static MCAsmInfo *createX86MCAsmInfo(con
   } else if (TheTriple.isOSBinFormatELF()) {
     // Force the use of an ELF container.
     MAI = new X86ELFMCAsmInfo(TheTriple);
-  } else if (TheTriple.isWindowsMSVCEnvironment()) {
+  } else if (TheTriple.isWindowsMSVCEnvironment() ||
+             TheTriple.isWindowsCoreCLREnvironment()) {
     MAI = new X86MCAsmInfoMicrosoft(TheTriple);
   } else if (TheTriple.isOSCygMing() ||
              TheTriple.isWindowsItaniumEnvironment()) {

Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=245115&r1=245114&r2=245115&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86Subtarget.h (original)
+++ llvm/trunk/lib/Target/X86/X86Subtarget.h Fri Aug 14 17:41:43 2015
@@ -406,6 +406,10 @@ public:
     return TargetTriple.isKnownWindowsMSVCEnvironment();
   }
 
+  bool isTargetWindowsCoreCLR() const {
+    return TargetTriple.isWindowsCoreCLREnvironment();
+  }
+
   bool isTargetWindowsCygwin() const {
     return TargetTriple.isWindowsCygwinEnvironment();
   }

Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=245115&r1=245114&r2=245115&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Fri Aug 14 17:41:43 2015
@@ -45,7 +45,7 @@ static std::unique_ptr<TargetLoweringObj
     return make_unique<X86LinuxNaClTargetObjectFile>();
   if (TT.isOSBinFormatELF())
     return make_unique<X86ELFTargetObjectFile>();
-  if (TT.isKnownWindowsMSVCEnvironment())
+  if (TT.isKnownWindowsMSVCEnvironment() || TT.isWindowsCoreCLREnvironment())
     return make_unique<X86WindowsTargetObjectFile>();
   if (TT.isOSBinFormatCOFF())
     return make_unique<TargetLoweringObjectFileCOFF>();

Modified: llvm/trunk/test/CodeGen/WinEH/seh-catch-all.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/seh-catch-all.ll?rev=245115&r1=245114&r2=245115&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WinEH/seh-catch-all.ll (original)
+++ llvm/trunk/test/CodeGen/WinEH/seh-catch-all.ll Fri Aug 14 17:41:43 2015
@@ -1,7 +1,7 @@
-; RUN: opt -S -winehprepare < %s | FileCheck %s
+; RUN: opt -S -winehprepare -mtriple=x86_64-pc-windows-msvc < %s | FileCheck %s
+; RUN: opt -S -winehprepare -mtriple=x86_64-pc-windows-coreclr < %s | FileCheck %s
 
 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-pc-windows-msvc"
 
 @str.__except = internal unnamed_addr constant [9 x i8] c"__except\00", align 1
 

Modified: llvm/trunk/test/CodeGen/WinEH/seh-inlined-finally.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/seh-inlined-finally.ll?rev=245115&r1=245114&r2=245115&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WinEH/seh-inlined-finally.ll (original)
+++ llvm/trunk/test/CodeGen/WinEH/seh-inlined-finally.ll Fri Aug 14 17:41:43 2015
@@ -1,10 +1,10 @@
-; RUN: opt -S -winehprepare < %s | FileCheck %s
+; RUN: opt -S -winehprepare -mtriple=x86_64-pc-windows-msvc < %s | FileCheck %s
+; RUN: opt -S -winehprepare -mtriple=x86_64-pc-windows-coreclr < %s | FileCheck %s
 
 ; Check that things work when the mid-level optimizer inlines the finally
 ; block.
 
 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-pc-windows-msvc"
 
 %struct._RTL_CRITICAL_SECTION = type { %struct._RTL_CRITICAL_SECTION_DEBUG*, i32, i32, i8*, i8*, i64 }
 %struct._RTL_CRITICAL_SECTION_DEBUG = type { i16, i16, %struct._RTL_CRITICAL_SECTION*, %struct._LIST_ENTRY, i32, i32, i32, i16, i16 }

Modified: llvm/trunk/test/CodeGen/WinEH/seh-outlined-finally.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/seh-outlined-finally.ll?rev=245115&r1=245114&r2=245115&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WinEH/seh-outlined-finally.ll (original)
+++ llvm/trunk/test/CodeGen/WinEH/seh-outlined-finally.ll Fri Aug 14 17:41:43 2015
@@ -1,4 +1,5 @@
 ; RUN: opt -S -winehprepare -mtriple=x86_64-windows-msvc < %s | FileCheck %s
+; RUN: opt -S -winehprepare -mtriple=x86_64-windows-coreclr < %s | FileCheck %s
 
 ; Test case based on this code:
 ;
@@ -26,7 +27,6 @@
 ; is nothing like a std::terminate call in this situation.
 
 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-pc-windows-msvc"
 
 @str_outer_finally = linkonce_odr unnamed_addr constant [18 x i8] c"outer finally %d\0A\00", align 1
 @str_inner_finally = linkonce_odr unnamed_addr constant [18 x i8] c"inner finally %d\0A\00", align 1

Modified: llvm/trunk/test/CodeGen/WinEH/seh-prepared-basic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/seh-prepared-basic.ll?rev=245115&r1=245114&r2=245115&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WinEH/seh-prepared-basic.ll (original)
+++ llvm/trunk/test/CodeGen/WinEH/seh-prepared-basic.ll Fri Aug 14 17:41:43 2015
@@ -1,4 +1,5 @@
-; RUN: llc < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-pc-windows-msvc < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-pc-windows-coreclr < %s | FileCheck %s
 
 ; Test case based on this code:
 ; extern "C" unsigned long _exception_code();
@@ -12,7 +13,6 @@
 ; }
 
 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-pc-windows-msvc"
 
 ; Function Attrs: uwtable
 define void @do_except() #0 personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) {

Modified: llvm/trunk/test/CodeGen/WinEH/seh-resume-phi.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/seh-resume-phi.ll?rev=245115&r1=245114&r2=245115&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WinEH/seh-resume-phi.ll (original)
+++ llvm/trunk/test/CodeGen/WinEH/seh-resume-phi.ll Fri Aug 14 17:41:43 2015
@@ -1,7 +1,7 @@
-; RUN: opt -S -winehprepare < %s | FileCheck %s
+; RUN: opt -S -winehprepare -mtriple=x86_64-pc-windows-msvc < %s | FileCheck %s
+; RUN: opt -S -winehprepare -mtriple=x86_64-pc-windows-coreclr < %s | FileCheck %s
 
 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-pc-windows-msvc"
 
 declare void @might_crash(i8* %ehptr)
 declare i32 @filt()

Modified: llvm/trunk/test/CodeGen/WinEH/seh-simple.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/seh-simple.ll?rev=245115&r1=245114&r2=245115&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WinEH/seh-simple.ll (original)
+++ llvm/trunk/test/CodeGen/WinEH/seh-simple.ll Fri Aug 14 17:41:43 2015
@@ -1,5 +1,7 @@
 ; RUN: opt -S -winehprepare -mtriple=x86_64-windows-msvc < %s \
 ; RUN: 		| FileCheck %s --check-prefix=CHECK --check-prefix=X64
+; RUN: opt -S -winehprepare -mtriple=x86_64-windows-coreclr < %s \
+; RUN: 		| FileCheck %s --check-prefix=CHECK --check-prefix=X64
 
 ; This test should also pass in 32-bit using _except_handler3.
 ; RUN: sed -e 's/__C_specific_handler/_except_handler3/' %s \

Modified: llvm/trunk/test/CodeGen/X86/stack-probe-size.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/stack-probe-size.ll?rev=245115&r1=245114&r2=245115&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/stack-probe-size.ll (original)
+++ llvm/trunk/test/CodeGen/X86/stack-probe-size.ll Fri Aug 14 17:41:43 2015
@@ -6,10 +6,10 @@
 ; stack probe size equals the page size (4096 bytes for all x86 targets), and
 ; this is unlikely to change in the future.
 ;
-; RUN: llc < %s | FileCheck %s
+; RUN: llc -mtriple=i686-windows-msvc < %s | FileCheck %s
+; RUN: llc -mtriple=i686-windows-coreclr < %s | FileCheck %s
 
 target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32"
-target triple = "i686-pc-windows-msvc"
 
 define i32 @test1() "stack-probe-size"="0" {
   %buffer = alloca [4095 x i8]




More information about the llvm-commits mailing list