OLD | NEW |
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 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 TargetLowering *TargetLowering::createLowering(TargetArch Target, Cfg *Func) { | 98 TargetLowering *TargetLowering::createLowering(TargetArch Target, Cfg *Func) { |
99 #define SUBZERO_TARGET(X) \ | 99 #define SUBZERO_TARGET(X) \ |
100 if (Target == Target_##X) \ | 100 if (Target == Target_##X) \ |
101 return Target##X::create(Func); | 101 return Target##X::create(Func); |
102 #include "llvm/Config/SZTargets.def" | 102 #include "llvm/Config/SZTargets.def" |
103 | 103 |
104 Func->setError("Unsupported target"); | 104 Func->setError("Unsupported target"); |
105 return nullptr; | 105 return nullptr; |
106 } | 106 } |
107 | 107 |
| 108 void TargetLowering::staticInit(TargetArch Target) { |
| 109 // Call the specified target's static initializer. |
| 110 switch (Target) { |
| 111 default: |
| 112 llvm::report_fatal_error("Unsupported target"); |
| 113 break; |
| 114 #define SUBZERO_TARGET(X) \ |
| 115 case Target_##X: { \ |
| 116 static bool InitGuard##X = false; \ |
| 117 if (InitGuard##X) \ |
| 118 return; \ |
| 119 InitGuard##X = true; \ |
| 120 Target##X::staticInit(); \ |
| 121 } break; |
| 122 #include "llvm/Config/SZTargets.def" |
| 123 } |
| 124 } |
| 125 |
108 TargetLowering::TargetLowering(Cfg *Func) | 126 TargetLowering::TargetLowering(Cfg *Func) |
109 : Func(Func), Ctx(Func->getContext()), Context() {} | 127 : Func(Func), Ctx(Func->getContext()), Context() {} |
110 | 128 |
111 std::unique_ptr<Assembler> TargetLowering::createAssembler(TargetArch Target, | 129 std::unique_ptr<Assembler> TargetLowering::createAssembler(TargetArch Target, |
112 Cfg *Func) { | 130 Cfg *Func) { |
113 #define SUBZERO_TARGET(X) \ | 131 #define SUBZERO_TARGET(X) \ |
114 if (Target == Target_##X) \ | 132 if (Target == Target_##X) \ |
115 return std::unique_ptr<Assembler>(new X::Assembler##X()); | 133 return std::unique_ptr<Assembler>(new X::Assembler##X()); |
116 #include "llvm/Config/SZTargets.def" | 134 #include "llvm/Config/SZTargets.def" |
117 | 135 |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 if (Target == Target_##X) \ | 643 if (Target == Target_##X) \ |
626 return TargetHeader##X::create(Ctx); | 644 return TargetHeader##X::create(Ctx); |
627 #include "llvm/Config/SZTargets.def" | 645 #include "llvm/Config/SZTargets.def" |
628 | 646 |
629 llvm::report_fatal_error("Unsupported target header lowering"); | 647 llvm::report_fatal_error("Unsupported target header lowering"); |
630 } | 648 } |
631 | 649 |
632 TargetHeaderLowering::~TargetHeaderLowering() = default; | 650 TargetHeaderLowering::~TargetHeaderLowering() = default; |
633 | 651 |
634 } // end of namespace Ice | 652 } // end of namespace Ice |
OLD | NEW |