Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: lib/Basic/Targets.cpp

Issue 1696583002: Remove Emscripten support (Closed) Base URL: https://chromium.googlesource.com/a/native_client/pnacl-clang.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/AST/ASTContext.cpp ('k') | lib/CodeGen/CodeGenModule.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===--- Targets.cpp - Implement -arch option and targets -----------------===// 1 //===--- Targets.cpp - Implement -arch option and targets -----------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file implements construction of a TargetInfo object from a 10 // This file implements construction of a TargetInfo object from a
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 switch (Triple.getArch()) { 266 switch (Triple.getArch()) {
267 default: 267 default:
268 case llvm::Triple::x86: 268 case llvm::Triple::x86:
269 case llvm::Triple::x86_64: 269 case llvm::Triple::x86_64:
270 this->MCountName = ".mcount"; 270 this->MCountName = ".mcount";
271 break; 271 break;
272 } 272 }
273 } 273 }
274 }; 274 };
275 275
276 // @LOCALMOD-START Emscripten
277 // Emscripten target
278 template <typename Target>
279 class EmscriptenTargetInfo : public OSTargetInfo<Target> {
280 protected:
281 void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
282 MacroBuilder &Builder) const override {
283 // A macro for the platform.
284 Builder.defineMacro("__EMSCRIPTEN__");
285 // Earlier versions of Emscripten defined this, so we continue to define it
286 // for compatibility, for now. Users should ideally prefer __EMSCRIPTEN__.
287 Builder.defineMacro("EMSCRIPTEN");
288 // A common platform macro.
289 if (Opts.POSIXThreads)
290 Builder.defineMacro("_REENTRANT");
291 // Follow g++ convention and predefine _GNU_SOURCE for C++.
292 if (Opts.CPlusPlus)
293 Builder.defineMacro("_GNU_SOURCE");
294
295 // Emscripten's software environment and the asm.js runtime aren't really
296 // Unix per se, but they're perhaps more Unix-like than what software
297 // expects when "unix" is *not* defined.
298 DefineStd(Builder, "unix", Opts);
299 }
300
301 public:
302 explicit EmscriptenTargetInfo(const llvm::Triple &Triple)
303 : OSTargetInfo<Target>(Triple) {
304 // Emcripten currently does prepend a prefix to user labels, but this is
305 // handled outside of clang. TODO: Handling this within clang may be
306 // beneficial.
307 this->UserLabelPrefix = "";
308 this->MaxAtomicPromoteWidth = this->MaxAtomicInlineWidth = 32;
309
310 // Emscripten uses the Itanium ABI mostly, but it uses ARM-style pointers
311 // to member functions so that it can avoid having to align function
312 // addresses.
313 this->TheCXXABI.set(TargetCXXABI::Emscripten);
314 }
315 };
316 // @LOCALMOD-END Emscripten
317
318 // FreeBSD Target 276 // FreeBSD Target
319 template<typename Target> 277 template<typename Target>
320 class FreeBSDTargetInfo : public OSTargetInfo<Target> { 278 class FreeBSDTargetInfo : public OSTargetInfo<Target> {
321 protected: 279 protected:
322 void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, 280 void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
323 MacroBuilder &Builder) const override { 281 MacroBuilder &Builder) const override {
324 // FreeBSD defines; list based off of gcc output 282 // FreeBSD defines; list based off of gcc output
325 283
326 unsigned Release = Triple.getOSMajorVersion(); 284 unsigned Release = Triple.getOSMajorVersion();
327 if (Release == 0U) 285 if (Release == 0U)
(...skipping 6132 matching lines...) Expand 10 before | Expand all | Expand 10 after
6460 BigEndian = false; 6418 BigEndian = false;
6461 } 6419 }
6462 void getTargetDefines(const LangOptions &Opts, 6420 void getTargetDefines(const LangOptions &Opts,
6463 MacroBuilder &Builder) const override { 6421 MacroBuilder &Builder) const override {
6464 DefineStd(Builder, "MIPSEL", Opts); 6422 DefineStd(Builder, "MIPSEL", Opts);
6465 Builder.defineMacro("_MIPSEL"); 6423 Builder.defineMacro("_MIPSEL");
6466 Mips64TargetInfoBase::getTargetDefines(Opts, Builder); 6424 Mips64TargetInfoBase::getTargetDefines(Opts, Builder);
6467 } 6425 }
6468 }; 6426 };
6469 6427
6470 // @LOCALMOD-START Emscripten
6471 namespace {
6472 class AsmJSTargetInfo : public TargetInfo {
6473 public:
6474 explicit AsmJSTargetInfo(const llvm::Triple &T) : TargetInfo(T) {
6475 BigEndian = false;
6476 NoAsmVariants = true;
6477 LongAlign = LongWidth = 32;
6478 PointerAlign = PointerWidth = 32;
6479 IntMaxType = Int64Type = TargetInfo::SignedLongLong;
6480 DoubleAlign = 64;
6481 LongDoubleWidth = LongDoubleAlign = 64;
6482 SizeType = TargetInfo::UnsignedInt;
6483 PtrDiffType = TargetInfo::SignedInt;
6484 IntPtrType = TargetInfo::SignedInt;
6485 RegParmMax = 0; // Disallow regparm
6486
6487 // Set the native integer widths set to just i32, since that's currently the
6488 // only integer type we can do arithmetic on without masking or splitting.
6489 //
6490 // Set the required alignment for 128-bit vectors to just 4 bytes, based on
6491 // the direction suggested here:
6492 // https://bugzilla.mozilla.org/show_bug.cgi?id=904913#c21
6493 // We can still set the preferred alignment to 16 bytes though.
6494 //
6495 // Set the natural stack alignment to 16 bytes to accomodate 128-bit aligned
6496 // vectors.
6497 DescriptionString = "e-p:32:32-i64:64-v128:32:128-n32-S128";
6498 }
6499
6500 void getDefaultFeatures(llvm::StringMap<bool> &Features) const override {}
6501 void getTargetDefines(const LangOptions &Opts,
6502 MacroBuilder &Builder) const override {
6503 defineCPUMacros(Builder, "asmjs", /*Tuning=*/false);
6504 }
6505 void getTargetBuiltins(const Builtin::Info *&Records,
6506 unsigned &NumRecords) const override {}
6507 BuiltinVaListKind getBuiltinVaListKind() const override {
6508 // Reuse PNaCl's va_list lowering.
6509 return TargetInfo::PNaClABIBuiltinVaList;
6510 }
6511 void getGCCRegNames(const char *const *&Names,
6512 unsigned &NumNames) const override {
6513 Names = nullptr;
6514 NumNames = 0;
6515 }
6516 void getGCCRegAliases(const GCCRegAlias *&Aliases,
6517 unsigned &NumAliases) const override {
6518 Aliases = nullptr;
6519 NumAliases = 0;
6520 }
6521 bool validateAsmConstraint(const char *&Name,
6522 TargetInfo::ConstraintInfo &Info) const override {
6523 return false;
6524 }
6525 const char *getClobbers() const override { return ""; }
6526 bool isCLZForZeroUndef() const override {
6527 // Today we do clz in software, so we just do the right thing. With ES6,
6528 // we'll get Math.clz32, which is to be defined to do the right thing:
6529 // http://esdiscuss.org/topic/rename-number-prototype-clz-to-math-clz#conten t-36
6530 return false;
6531 }
6532 };
6533 } // end anonymous namespace.
6534 // @LOCALMOD-END Emscripten
6535
6536 class PNaClTargetInfo : public TargetInfo { 6428 class PNaClTargetInfo : public TargetInfo {
6537 public: 6429 public:
6538 PNaClTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) { 6430 PNaClTargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
6539 BigEndian = false; 6431 BigEndian = false;
6540 this->UserLabelPrefix = ""; 6432 this->UserLabelPrefix = "";
6541 this->LongAlign = 32; 6433 this->LongAlign = 32;
6542 this->LongWidth = 32; 6434 this->LongWidth = 32;
6543 this->PointerAlign = 32; 6435 this->PointerAlign = 32;
6544 this->PointerWidth = 32; 6436 this->PointerWidth = 32;
6545 this->IntMaxType = TargetInfo::SignedLongLong; 6437 this->IntMaxType = TargetInfo::SignedLongLong;
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
7006 case llvm::Triple::FreeBSD: 6898 case llvm::Triple::FreeBSD:
7007 return new FreeBSDTargetInfo<Mips64ELTargetInfo>(Triple); 6899 return new FreeBSDTargetInfo<Mips64ELTargetInfo>(Triple);
7008 case llvm::Triple::NetBSD: 6900 case llvm::Triple::NetBSD:
7009 return new NetBSDTargetInfo<Mips64ELTargetInfo>(Triple); 6901 return new NetBSDTargetInfo<Mips64ELTargetInfo>(Triple);
7010 case llvm::Triple::OpenBSD: 6902 case llvm::Triple::OpenBSD:
7011 return new OpenBSDTargetInfo<Mips64ELTargetInfo>(Triple); 6903 return new OpenBSDTargetInfo<Mips64ELTargetInfo>(Triple);
7012 default: 6904 default:
7013 return new Mips64ELTargetInfo(Triple); 6905 return new Mips64ELTargetInfo(Triple);
7014 } 6906 }
7015 6907
7016 // @LOCALMOD-START Emscripten
7017 case llvm::Triple::asmjs:
7018 switch (os) {
7019 case llvm::Triple::Emscripten:
7020 return new EmscriptenTargetInfo<AsmJSTargetInfo>(Triple);
7021 default:
7022 return nullptr;
7023 }
7024 // @LOCALMOD-END Emscripten
7025
7026 case llvm::Triple::le32: 6908 case llvm::Triple::le32:
7027 switch (os) { 6909 switch (os) {
7028 case llvm::Triple::NaCl: 6910 case llvm::Triple::NaCl:
7029 return new NaClTargetInfo<PNaClTargetInfo>(Triple); 6911 return new NaClTargetInfo<PNaClTargetInfo>(Triple);
7030 default: 6912 default:
7031 return nullptr; 6913 return nullptr;
7032 } 6914 }
7033 6915
7034 case llvm::Triple::le64: 6916 case llvm::Triple::le64:
7035 return new Le64TargetInfo(Triple); 6917 return new Le64TargetInfo(Triple);
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
7302 if (!Target->handleTargetFeatures(Opts->Features, Diags)) 7184 if (!Target->handleTargetFeatures(Opts->Features, Diags))
7303 return nullptr; 7185 return nullptr;
7304 7186
7305 // @LOCALMOD-START 7187 // @LOCALMOD-START
7306 if (!Target->handleLLVMArgs(Opts->LLVMArgs)) 7188 if (!Target->handleLLVMArgs(Opts->LLVMArgs))
7307 return nullptr; 7189 return nullptr;
7308 // @LOCALMOD-END 7190 // @LOCALMOD-END
7309 7191
7310 return Target.release(); 7192 return Target.release();
7311 } 7193 }
OLDNEW
« no previous file with comments | « lib/AST/ASTContext.cpp ('k') | lib/CodeGen/CodeGenModule.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698