blob: 922944e85ca29536c2679db124f9679013b40f3d [file] [log] [blame]
Erich Keaneebba5922017-07-21 22:37:03 +00001//===--- PNaCl.h - Declare PNaCl target feature support ---------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file declares PNaCl TargetInfo objects.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_PNACL_H
15#define LLVM_CLANG_LIB_BASIC_TARGETS_PNACL_H
16
17#include "Mips.h"
18#include "clang/Basic/TargetInfo.h"
19#include "clang/Basic/TargetOptions.h"
20#include "llvm/ADT/Triple.h"
21#include "llvm/Support/Compiler.h"
22
23namespace clang {
24namespace targets {
25
26class LLVM_LIBRARY_VISIBILITY PNaClTargetInfo : public TargetInfo {
27public:
28 PNaClTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
29 : TargetInfo(Triple) {
30 this->LongAlign = 32;
31 this->LongWidth = 32;
32 this->PointerAlign = 32;
33 this->PointerWidth = 32;
34 this->IntMaxType = TargetInfo::SignedLongLong;
35 this->Int64Type = TargetInfo::SignedLongLong;
36 this->DoubleAlign = 64;
37 this->LongDoubleWidth = 64;
38 this->LongDoubleAlign = 64;
39 this->SizeType = TargetInfo::UnsignedInt;
40 this->PtrDiffType = TargetInfo::SignedInt;
41 this->IntPtrType = TargetInfo::SignedInt;
42 this->RegParmMax = 0; // Disallow regparm
43 }
44
45 void getArchDefines(const LangOptions &Opts, MacroBuilder &Builder) const;
46
47 void getTargetDefines(const LangOptions &Opts,
48 MacroBuilder &Builder) const override {
49 getArchDefines(Opts, Builder);
50 }
51
52 bool hasFeature(StringRef Feature) const override {
53 return Feature == "pnacl";
54 }
55
56 ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
57
58 BuiltinVaListKind getBuiltinVaListKind() const override {
59 return TargetInfo::PNaClABIBuiltinVaList;
60 }
61
62 ArrayRef<const char *> getGCCRegNames() const override;
63
64 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
65
66 bool validateAsmConstraint(const char *&Name,
67 TargetInfo::ConstraintInfo &Info) const override {
68 return false;
69 }
70
71 const char *getClobbers() const override { return ""; }
72};
73
74// We attempt to use PNaCl (le32) frontend and Mips32EL backend.
75class LLVM_LIBRARY_VISIBILITY NaClMips32TargetInfo : public MipsTargetInfo {
76public:
77 NaClMips32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
78 : MipsTargetInfo(Triple, Opts) {}
79
80 BuiltinVaListKind getBuiltinVaListKind() const override {
81 return TargetInfo::PNaClABIBuiltinVaList;
82 }
83};
84} // namespace targets
85} // namespace clang
86
87#endif // LLVM_CLANG_LIB_BASIC_TARGETS_PNACL_H