aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Voung <jvoung@chromium.org>2013-08-28 14:54:59 -0700
committerJan Voung <jvoung@chromium.org>2013-08-28 14:54:59 -0700
commitfa8d800195480df6eb76f4ea51a18cca9cb5ff88 (patch)
tree13e3586bbfb7dbf24dbe5a18b6bb0ea9f9cdf0f1
parent493d4ab9edba2be18c916d80aaa100a0e51e1f51 (diff)
Hardcode NaCl in ADT/Triple.h for NaCl only builds (no Darwin/Windows).
Ideally, OS-specific code would be factored out, but there are currently tons of "if (T.isOSBlah())" everywhere. E.g., 57 hits for isTargetDarwin, 36 hits for isOSDarwin, 45 hits for "getOS(", 23 hits for isMacOSX, etc... Hacking Triple.h gets us most of the way there. The X86 code also requires hacking the getEnvironment() to never return the Darwin enum value. We can't just return GNU always, because for ARM we want GNUEABIHF. There is still *some* MachO and COFF code because of code that handles container-specific relocations without checking the OS first. This prunes between 100KB to 200 KB per target (~100KB for ARM, and ~200KB for x86-64). See https://codereview.chromium.org/23540008/ for the test. BUG=https://code.google.com/p/nativeclient/issues/detail?id=1222 BUG=https://code.google.com/p/nativeclient/issues/detail?id=3321 R=dschuff@chromium.org, jfb@chromium.org Review URL: https://codereview.chromium.org/23453014
-rw-r--r--include/llvm/ADT/Triple.h38
1 files changed, 35 insertions, 3 deletions
diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h
index 3a72e8704f..7ee1d724e8 100644
--- a/include/llvm/ADT/Triple.h
+++ b/include/llvm/ADT/Triple.h
@@ -168,18 +168,34 @@ public:
/// getVendor - Get the parsed vendor type of this triple.
VendorType getVendor() const { return Vendor; }
+ // @LOCALMOD-BEGIN -- hardcode NaCl for NaCl builds, to help
+ // prune OS-specific code that is litered all over and not
+ // cleanly separated.
+#if defined(__native_client__)
+ OSType getOS() const { return NaCl; }
+ EnvironmentType getEnvironment() const {
+ // The X86 backend checks OS || Environment == MachO, so we need to hack
+ // the environment as well to make MachO impossible.
+ if (Environment == MachO) {
+ report_fatal_error("NaCl-specific build doesn't handle MachO");
+ }
+ return Environment;
+ }
+#else
/// getOS - Get the parsed operating system type of this triple.
OSType getOS() const { return OS; }
+ /// getEnvironment - Get the parsed environment type of this triple.
+ EnvironmentType getEnvironment() const { return Environment; }
+#endif
+ // @LOCALMOD-END
+
/// hasEnvironment - Does this triple have the optional environment
/// (fourth) component?
bool hasEnvironment() const {
return getEnvironmentName() != "";
}
- /// getEnvironment - Get the parsed environment type of this triple.
- EnvironmentType getEnvironment() const { return Environment; }
-
/// getOSVersion - Parse the version number from the OS name component of the
/// triple, if present.
///
@@ -292,6 +308,20 @@ public:
return isOSVersionLT(Minor + 4, Micro, 0);
}
+ // @LOCALMOD-BEGIN: Hardcode OS predicates to help prune code
+ // that is OS-specific, but not cleanly separated.
+ // Perhaps this would be cleaner if Triple.h was partly Table-gen'ed.
+#if defined(__native_client__)
+ bool isMacOSX() const { return false; }
+ bool isiOS() const { return false; }
+ bool isOSDarwin() const { return false; }
+ bool isOSCygMing() const { return false; }
+ bool isOSWindows() const { return false; }
+ bool isOSNaCl() const { return true; }
+ bool isOSBinFormatELF() const { return true; }
+ bool isOSBinFormatCOFF() const { return false; }
+ bool isEnvironmentMachO() const { return false; }
+#else
/// isMacOSX - Is this a Mac OS X triple. For legacy reasons, we support both
/// "darwin" and "osx" as OS X triples.
bool isMacOSX() const {
@@ -338,6 +368,8 @@ public:
bool isEnvironmentMachO() const {
return getEnvironment() == Triple::MachO || isOSDarwin();
}
+#endif
+ // @LOCALMOD-END
/// @}
/// @name Mutators