[PATCH] D23610: [ARM] Add pre-defined macros for ROPI and RWPI
Oliver Stannard via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 16 06:20:53 PDT 2017
olista01 updated this revision to Diff 91990.
olista01 retitled this revision from "[ARM] Add pre-defined macros for ROPI, RWPI and FPIC" to "[ARM] Add pre-defined macros for ROPI and RWPI".
olista01 edited the summary of this revision.
Repository:
rL LLVM
https://reviews.llvm.org/D23610
Files:
include/clang/Basic/LangOptions.def
include/clang/Driver/Options.td
lib/Basic/Targets.cpp
lib/Driver/ToolChains/Clang.cpp
lib/Frontend/CompilerInvocation.cpp
test/Preprocessor/arm-pic-predefines.c
Index: test/Preprocessor/arm-pic-predefines.c
===================================================================
--- /dev/null
+++ test/Preprocessor/arm-pic-predefines.c
@@ -0,0 +1,14 @@
+// REQUIRES: arm-registered-target
+
+// RUN: %clang -target armv8--none-eabi -x c -E -dM %s -o - | FileCheck %s --check-prefix=NO-ROPI --check-prefix=NO-RWPI
+// RUN: %clang -target armv8--none-eabi -x c -E -dM %s -o - -fropi | FileCheck %s --check-prefix=ROPI --check-prefix=NO-RWPI
+// RUN: %clang -target armv8--none-eabi -x c -E -dM %s -o - -frwpi | FileCheck %s --check-prefix=NO-ROPI --check-prefix=RWPI
+// RUN: %clang -target armv8--none-eabi -x c -E -dM %s -o - -fropi -frwpi | FileCheck %s --check-prefix=ROPI --check-prefix=RWPI
+
+// Pre-defined macros for position-independence modes
+
+// NO-ROPI-NOT: #define __APCS_ROPI
+// ROPI: #define __ARM_ROPI
+
+// NO-RWPI-NOT: #define __APCS_RWPI
+// RWPI: #define __ARM_RWPI
Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2071,6 +2071,8 @@
Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, Diags);
Opts.AlignDouble = Args.hasArg(OPT_malign_double);
Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
+ Opts.ROPI = Args.hasArg(OPT_fropi);
+ Opts.RWPI = Args.hasArg(OPT_frwpi);
Opts.PIE = Args.hasArg(OPT_pic_is_pie);
Opts.Static = Args.hasArg(OPT_static_define);
Opts.DumpRecordLayoutsSimple = Args.hasArg(OPT_fdump_record_layouts_simple);
Index: lib/Driver/ToolChains/Clang.cpp
===================================================================
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2193,6 +2193,13 @@
CmdArgs.push_back("-pic-is-pie");
}
+ if (RelocationModel == llvm::Reloc::ROPI ||
+ RelocationModel == llvm::Reloc::ROPI_RWPI)
+ CmdArgs.push_back("-fropi");
+ if (RelocationModel == llvm::Reloc::RWPI ||
+ RelocationModel == llvm::Reloc::ROPI_RWPI)
+ CmdArgs.push_back("-frwpi");
+
if (Arg *A = Args.getLastArg(options::OPT_meabi)) {
CmdArgs.push_back("-meabi");
CmdArgs.push_back(A->getValue());
Index: lib/Basic/Targets.cpp
===================================================================
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -5577,6 +5577,12 @@
if (ArchKind == llvm::ARM::AK_ARMV8_1A)
Builder.defineMacro("__ARM_FEATURE_QRDMX", "1");
+
+ // ACLE position independent code macros.
+ if (Opts.ROPI)
+ Builder.defineMacro("__ARM_ROPI", "1");
+ if (Opts.RWPI)
+ Builder.defineMacro("__ARM_RWPI", "1");
}
ArrayRef<Builtin::Info> getTargetBuiltins() const override {
Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1275,9 +1275,9 @@
def fno_pic : Flag<["-"], "fno-pic">, Group<f_Group>;
def fpie : Flag<["-"], "fpie">, Group<f_Group>;
def fno_pie : Flag<["-"], "fno-pie">, Group<f_Group>;
-def fropi : Flag<["-"], "fropi">, Group<f_Group>;
+def fropi : Flag<["-"], "fropi">, Group<f_Group>, Flags<[CC1Option]>;
def fno_ropi : Flag<["-"], "fno-ropi">, Group<f_Group>;
-def frwpi : Flag<["-"], "frwpi">, Group<f_Group>;
+def frwpi : Flag<["-"], "frwpi">, Group<f_Group>, Flags<[CC1Option]>;
def fno_rwpi : Flag<["-"], "fno-rwpi">, Group<f_Group>;
def fplugin_EQ : Joined<["-"], "fplugin=">, Group<f_Group>, Flags<[DriverOption]>, MetaVarName<"<dsopath>">,
HelpText<"Load the named plugin (dynamic shared object)">;
Index: include/clang/Basic/LangOptions.def
===================================================================
--- include/clang/Basic/LangOptions.def
+++ include/clang/Basic/LangOptions.def
@@ -163,6 +163,8 @@
VALUE_LANGOPT(AlignDouble , 1, 0, "Controls if doubles should be aligned to 8 bytes (x86 only)")
COMPATIBLE_VALUE_LANGOPT(PICLevel , 2, 0, "__PIC__ level")
COMPATIBLE_VALUE_LANGOPT(PIE , 1, 0, "is pie")
+LANGOPT(ROPI , 1, 0, "Read-only position independence")
+LANGOPT(RWPI , 1, 0, "Read-write position independence")
COMPATIBLE_LANGOPT(GNUInline , 1, 0, "GNU inline semantics")
COMPATIBLE_LANGOPT(NoInlineDefine , 1, 0, "__NO_INLINE__ predefined macro")
COMPATIBLE_LANGOPT(Deprecated , 1, 0, "__DEPRECATED predefined macro")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23610.91990.patch
Type: text/x-patch
Size: 4527 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170316/a4adc949/attachment.bin>
More information about the cfe-commits
mailing list