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

Side by Side Diff: src/IceTargetLowering.cpp

Issue 1787143002: Subzero: Allow Makefile.standalone to build for a single target. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fixed macro Created 4 years, 9 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 | « src/IceCompileServer.cpp ('k') | src/SZTargets.def » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceTargetLowering.cpp - Basic lowering implementation --===// 1 //===- subzero/src/IceTargetLowering.cpp - Basic lowering implementation --===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
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 /// \file 10 /// \file
11 /// \brief Implements the skeleton of the TargetLowering class. 11 /// \brief Implements the skeleton of the TargetLowering class.
12 /// 12 ///
13 /// Specifically this invokes the appropriate lowering method for a given 13 /// Specifically this invokes the appropriate lowering method for a given
14 /// instruction kind and driving global register allocation. It also implements 14 /// instruction kind and driving global register allocation. It also implements
15 /// the non-deleted instruction iteration in LoweringContext. 15 /// the non-deleted instruction iteration in LoweringContext.
16 /// 16 ///
17 //===----------------------------------------------------------------------===// 17 //===----------------------------------------------------------------------===//
18 18
19 #include "IceTargetLowering.h" 19 #include "IceTargetLowering.h"
20 20
21 #include "IceBitVector.h" 21 #include "IceBitVector.h"
22 #include "IceCfg.h" // setError() 22 #include "IceCfg.h" // setError()
23 #include "IceCfgNode.h" 23 #include "IceCfgNode.h"
24 #include "IceGlobalContext.h" 24 #include "IceGlobalContext.h"
25 #include "IceGlobalInits.h" 25 #include "IceGlobalInits.h"
26 #include "IceInstVarIter.h" 26 #include "IceInstVarIter.h"
27 #include "IceOperand.h" 27 #include "IceOperand.h"
28 #include "IceRegAlloc.h" 28 #include "IceRegAlloc.h"
29 29
30 #define TARGET_LOWERING_CLASS_FOR(t) Target_##t
31
30 // We prevent target-specific implementation details from leaking outside their 32 // We prevent target-specific implementation details from leaking outside their
31 // implementations by forbidding #include of target-specific header files 33 // implementations by forbidding #include of target-specific header files
32 // anywhere outside their own files. To create target-specific objects 34 // anywhere outside their own files. To create target-specific objects
33 // (TargetLowering, TargetDataLowering, and TargetHeaderLowering) we use the 35 // (TargetLowering, TargetDataLowering, and TargetHeaderLowering) we use the
34 // following named constructors. For reference, each target Foo needs to 36 // following named constructors. For reference, each target Foo needs to
35 // implement the following named constructors and initializer: 37 // implement the following named constructors and initializer:
36 // 38 //
37 // namespace Foo { 39 // namespace Foo {
38 // unique_ptr<Ice::TargetLowering> createTargetLowering(Ice::Cfg *); 40 // unique_ptr<Ice::TargetLowering> createTargetLowering(Ice::Cfg *);
39 // unique_ptr<Ice::TargetDataLowering> 41 // unique_ptr<Ice::TargetDataLowering>
40 // createTargetDataLowering(Ice::GlobalContext*); 42 // createTargetDataLowering(Ice::GlobalContext*);
41 // unique_ptr<Ice::TargetHeaderLowering> 43 // unique_ptr<Ice::TargetHeaderLowering>
42 // createTargetHeaderLowering(Ice::GlobalContext *); 44 // createTargetHeaderLowering(Ice::GlobalContext *);
43 // void staticInit(::Ice::GlobalContext *); 45 // void staticInit(::Ice::GlobalContext *);
44 // } 46 // }
45 #define SUBZERO_TARGET(X) \ 47 #define SUBZERO_TARGET(X) \
46 namespace X { \ 48 namespace X { \
47 std::unique_ptr<::Ice::TargetLowering> \ 49 std::unique_ptr<::Ice::TargetLowering> \
48 createTargetLowering(::Ice::Cfg *Func); \ 50 createTargetLowering(::Ice::Cfg *Func); \
49 std::unique_ptr<::Ice::TargetDataLowering> \ 51 std::unique_ptr<::Ice::TargetDataLowering> \
50 createTargetDataLowering(::Ice::GlobalContext *Ctx); \ 52 createTargetDataLowering(::Ice::GlobalContext *Ctx); \
51 std::unique_ptr<::Ice::TargetHeaderLowering> \ 53 std::unique_ptr<::Ice::TargetHeaderLowering> \
52 createTargetHeaderLowering(::Ice::GlobalContext *Ctx); \ 54 createTargetHeaderLowering(::Ice::GlobalContext *Ctx); \
53 void staticInit(::Ice::GlobalContext *Ctx); \ 55 void staticInit(::Ice::GlobalContext *Ctx); \
54 } // end of namespace X 56 } // end of namespace X
55 #include "llvm/Config/SZTargets.def" 57 #include "SZTargets.def"
56 #undef SUBZERO_TARGET 58 #undef SUBZERO_TARGET
57 59
58 namespace Ice { 60 namespace Ice {
59 void LoweringContext::init(CfgNode *N) { 61 void LoweringContext::init(CfgNode *N) {
60 Node = N; 62 Node = N;
61 End = getNode()->getInsts().end(); 63 End = getNode()->getInsts().end();
62 rewind(); 64 rewind();
63 advanceForward(Next); 65 advanceForward(Next);
64 } 66 }
65 67
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 Str << "\n"; 245 Str << "\n";
244 } 246 }
245 } 247 }
246 248
247 std::unique_ptr<TargetLowering> 249 std::unique_ptr<TargetLowering>
248 TargetLowering::createLowering(TargetArch Target, Cfg *Func) { 250 TargetLowering::createLowering(TargetArch Target, Cfg *Func) {
249 switch (Target) { 251 switch (Target) {
250 default: 252 default:
251 badTargetFatalError(Target); 253 badTargetFatalError(Target);
252 #define SUBZERO_TARGET(X) \ 254 #define SUBZERO_TARGET(X) \
253 case Target_##X: \ 255 case TARGET_LOWERING_CLASS_FOR(X): \
254 return ::X::createTargetLowering(Func); 256 return ::X::createTargetLowering(Func);
255 #include "llvm/Config/SZTargets.def" 257 #include "SZTargets.def"
256 #undef SUBZERO_TARGET 258 #undef SUBZERO_TARGET
257 } 259 }
258 } 260 }
259 261
260 void TargetLowering::staticInit(GlobalContext *Ctx) { 262 void TargetLowering::staticInit(GlobalContext *Ctx) {
261 const TargetArch Target = Ctx->getFlags().getTargetArch(); 263 const TargetArch Target = Ctx->getFlags().getTargetArch();
262 // Call the specified target's static initializer. 264 // Call the specified target's static initializer.
263 switch (Target) { 265 switch (Target) {
264 default: 266 default:
265 badTargetFatalError(Target); 267 badTargetFatalError(Target);
266 #define SUBZERO_TARGET(X) \ 268 #define SUBZERO_TARGET(X) \
267 case Target_##X: { \ 269 case TARGET_LOWERING_CLASS_FOR(X): { \
268 static bool InitGuard##X = false; \ 270 static bool InitGuard##X = false; \
269 if (InitGuard##X) { \ 271 if (InitGuard##X) { \
270 return; \ 272 return; \
271 } \ 273 } \
272 InitGuard##X = true; \ 274 InitGuard##X = true; \
273 ::X::staticInit(Ctx); \ 275 ::X::staticInit(Ctx); \
274 } break; 276 } break;
275 #include "llvm/Config/SZTargets.def" 277 #include "SZTargets.def"
276 #undef SUBZERO_TARGET 278 #undef SUBZERO_TARGET
277 } 279 }
278 } 280 }
279 281
280 TargetLowering::SandboxType 282 TargetLowering::SandboxType
281 TargetLowering::determineSandboxTypeFromFlags(const ClFlags &Flags) { 283 TargetLowering::determineSandboxTypeFromFlags(const ClFlags &Flags) {
282 assert(!Flags.getUseSandboxing() || !Flags.getUseNonsfi()); 284 assert(!Flags.getUseSandboxing() || !Flags.getUseNonsfi());
283 if (Flags.getUseNonsfi()) { 285 if (Flags.getUseNonsfi()) {
284 return TargetLowering::ST_Nonsfi; 286 return TargetLowering::ST_Nonsfi;
285 } 287 }
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 } 741 }
740 } 742 }
741 743
742 std::unique_ptr<TargetDataLowering> 744 std::unique_ptr<TargetDataLowering>
743 TargetDataLowering::createLowering(GlobalContext *Ctx) { 745 TargetDataLowering::createLowering(GlobalContext *Ctx) {
744 TargetArch Target = Ctx->getFlags().getTargetArch(); 746 TargetArch Target = Ctx->getFlags().getTargetArch();
745 switch (Target) { 747 switch (Target) {
746 default: 748 default:
747 badTargetFatalError(Target); 749 badTargetFatalError(Target);
748 #define SUBZERO_TARGET(X) \ 750 #define SUBZERO_TARGET(X) \
749 case Target_##X: \ 751 case TARGET_LOWERING_CLASS_FOR(X): \
750 return ::X::createTargetDataLowering(Ctx); 752 return ::X::createTargetDataLowering(Ctx);
751 #include "llvm/Config/SZTargets.def" 753 #include "SZTargets.def"
752 #undef SUBZERO_TARGET 754 #undef SUBZERO_TARGET
753 } 755 }
754 } 756 }
755 757
756 TargetDataLowering::~TargetDataLowering() = default; 758 TargetDataLowering::~TargetDataLowering() = default;
757 759
758 namespace { 760 namespace {
759 761
760 // dataSectionSuffix decides whether to use SectionSuffix or VarName as data 762 // dataSectionSuffix decides whether to use SectionSuffix or VarName as data
761 // section suffix. Essentially, when using separate data sections for globals 763 // section suffix. Essentially, when using separate data sections for globals
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 Str << "\t.size\t" << Name << ", " << Size << "\n"; 872 Str << "\t.size\t" << Name << ", " << Size << "\n";
871 } 873 }
872 874
873 std::unique_ptr<TargetHeaderLowering> 875 std::unique_ptr<TargetHeaderLowering>
874 TargetHeaderLowering::createLowering(GlobalContext *Ctx) { 876 TargetHeaderLowering::createLowering(GlobalContext *Ctx) {
875 TargetArch Target = Ctx->getFlags().getTargetArch(); 877 TargetArch Target = Ctx->getFlags().getTargetArch();
876 switch (Target) { 878 switch (Target) {
877 default: 879 default:
878 badTargetFatalError(Target); 880 badTargetFatalError(Target);
879 #define SUBZERO_TARGET(X) \ 881 #define SUBZERO_TARGET(X) \
880 case Target_##X: \ 882 case TARGET_LOWERING_CLASS_FOR(X): \
881 return ::X::createTargetHeaderLowering(Ctx); 883 return ::X::createTargetHeaderLowering(Ctx);
882 #include "llvm/Config/SZTargets.def" 884 #include "SZTargets.def"
883 #undef SUBZERO_TARGET 885 #undef SUBZERO_TARGET
884 } 886 }
885 } 887 }
886 888
887 TargetHeaderLowering::~TargetHeaderLowering() = default; 889 TargetHeaderLowering::~TargetHeaderLowering() = default;
888 890
889 } // end of namespace Ice 891 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCompileServer.cpp ('k') | src/SZTargets.def » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698