r208486 - CodeGen: support dll{ex,im}port on WoA

Saleem Abdulrasool compnerd at compnerd.org
Sat May 10 18:31:57 PDT 2014


Author: compnerd
Date: Sat May 10 20:31:57 2014
New Revision: 208486

URL: http://llvm.org/viewvc/llvm-project?rev=208486&view=rev
Log:
CodeGen: support dll{ex,im}port on WoA

Add ARM support for dllexport and dllimport attributes.  This is a relatively
conservative change.  The alternative is to entirely drop the architecture
requirement.  The dllimport and dllexport attributes are not restricted to any
architecture, simply to platforms that support this attribute (currently
Windows).

Added:
    cfe/trunk/test/CodeGen/windows-on-arm-dllimport-dllexport.c
Modified:
    cfe/trunk/include/clang/Basic/Attr.td

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=208486&r1=208485&r2=208486&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Sat May 10 20:31:57 2014
@@ -233,7 +233,7 @@ class TargetArch<list<string> arches> {
 def TargetARM : TargetArch<["arm", "thumb"]>;
 def TargetMSP430 : TargetArch<["msp430"]>;
 def TargetX86 : TargetArch<["x86"]>;
-def TargetX86Win : TargetArch<["x86", "x86_64"]> {
+def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb"]> {
   let OSes = ["Win32"];
 }
 def TargetMips : TargetArch<["mips", "mipsel"]>;
@@ -1645,13 +1645,13 @@ def MsStruct : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
-def DLLExport : InheritableAttr, TargetSpecificAttr<TargetX86Win> {
+def DLLExport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
   let Spellings = [Declspec<"dllexport">, GCC<"dllexport">];
   let Subjects = SubjectList<[Function, Var]>;
   let Documentation = [Undocumented];
 }
 
-def DLLImport : InheritableAttr, TargetSpecificAttr<TargetX86Win> {
+def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
   let Spellings = [Declspec<"dllimport">, GCC<"dllimport">];
   // Technically, the subjects for DllImport are Function and Var, but there is
   // custom semantic handling required when MicrosoftExt is true.

Added: cfe/trunk/test/CodeGen/windows-on-arm-dllimport-dllexport.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/windows-on-arm-dllimport-dllexport.c?rev=208486&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/windows-on-arm-dllimport-dllexport.c (added)
+++ cfe/trunk/test/CodeGen/windows-on-arm-dllimport-dllexport.c Sat May 10 20:31:57 2014
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -Werror -triple thumbv7-windows-itanium -mfloat-abi hard -emit-llvm %s -o - | FileCheck %s
+
+__declspec(dllexport) int export_int;
+
+__declspec(dllimport) int import_int;
+
+__declspec(dllexport) void export_declared_function();
+
+__declspec(dllexport) void export_implemented_function() {
+}
+
+__declspec(dllimport) void import_function(int);
+
+void call_imported_function() {
+  export_declared_function();
+  return import_function(import_int);
+}
+
+// CHECK: @import_int = external dllimport global i32
+// CHECK: @export_int = common dllexport global i32 0, align 4
+
+// CHECK: define dllexport arm_aapcs_vfpcc void @export_implemented_function()
+
+// CHECK: declare dllimport arm_aapcs_vfpcc void @import_function(i32)
+





More information about the cfe-commits mailing list