Chromium Code Reviews| Index: src/IceTargetLowering.cpp |
| diff --git a/src/IceTargetLowering.cpp b/src/IceTargetLowering.cpp |
| index 39d27fe213551d14f26081886882dcd74a5fd2ab..1ccc52a39978617c58e07746b669572821e0155e 100644 |
| --- a/src/IceTargetLowering.cpp |
| +++ b/src/IceTargetLowering.cpp |
| @@ -15,6 +15,7 @@ |
| // |
| //===----------------------------------------------------------------------===// |
| +#include "assembler_arm32.h" |
| #include "assembler_ia32.h" |
| #include "IceCfg.h" // setError() |
| #include "IceCfgNode.h" |
| @@ -22,6 +23,7 @@ |
| #include "IceRegAlloc.h" |
| #include "IceTargetLowering.h" |
| #include "IceTargetLoweringX8632.h" |
| +#include "IceTargetLoweringARM32.h" |
|
Jim Stichnoth
2015/04/17 19:16:01
alphabetize
jvoung (off chromium)
2015/04/21 17:05:30
Done.
|
| namespace Ice { |
| @@ -62,18 +64,13 @@ Inst *LoweringContext::getLastInserted() const { |
| } |
| TargetLowering *TargetLowering::createLowering(TargetArch Target, Cfg *Func) { |
| - // These statements can be #ifdef'd to specialize the code generator |
| - // to a subset of the available targets. TODO: use CRTP. |
| - if (Target == Target_X8632) |
| - return TargetX8632::create(Func); |
| -#if 0 |
| - if (Target == Target_X8664) |
| - return IceTargetX8664::create(Func); |
| - if (Target == Target_ARM32) |
| - return IceTargetARM32::create(Func); |
| - if (Target == Target_ARM64) |
| - return IceTargetARM64::create(Func); |
| -#endif |
| +// These statements can be #ifdef'd to specialize the code generator |
|
Jim Stichnoth
2015/04/17 19:16:01
hmm, surprised that the comment indent changed...
jvoung (off chromium)
2015/04/21 17:05:30
Hmm some clang-format artifact? I couldn't convinc
|
| +// to a subset of the available targets. TODO: use CRTP. |
| +#define SUBZERO_TARGET(X) \ |
| + if (Target == Target_##X) \ |
| + return Target##X::create(Func); |
| +#include "llvm/Config/SZTargets.def" |
| + |
| Func->setError("Unsupported target"); |
| return nullptr; |
| } |
| @@ -87,9 +84,15 @@ std::unique_ptr<Assembler> TargetLowering::createAssembler(TargetArch Target, |
| Cfg *Func) { |
| // These statements can be #ifdef'd to specialize the assembler |
| // to a subset of the available targets. TODO: use CRTP. |
| + // TODO(jvoung): use SZTargets.def (rename AssemblerX86 -> AssemblerX8632), |
| + // and make the namespaces consistent. |
| if (Target == Target_X8632) |
| return std::unique_ptr<Assembler>(new x86::AssemblerX86()); |
| - Func->setError("Unsupported target"); |
| + |
| + if (Target == Target_ARM32) |
| + return std::unique_ptr<Assembler>(new AssemblerARM32()); |
| + |
| + Func->setError("Unsupported target assembler"); |
| return nullptr; |
| } |
| @@ -234,17 +237,12 @@ TargetDataLowering::createLowering(GlobalContext *Ctx) { |
| // These statements can be #ifdef'd to specialize the code generator |
| // to a subset of the available targets. TODO: use CRTP. |
| TargetArch Target = Ctx->getFlags().getTargetArch(); |
| - if (Target == Target_X8632) |
| - return std::unique_ptr<TargetDataLowering>(TargetDataX8632::create(Ctx)); |
| -#if 0 |
| - if (Target == Target_X8664) |
| - return std::unique_ptr<TargetDataLowering>(TargetDataX8664::create(Ctx)); |
| - if (Target == Target_ARM32) |
| - return std::unique_ptr<TargetDataLowering>(TargetDataARM32::create(Ctx)); |
| - if (Target == Target_ARM64) |
| - return std::unique_ptr<TargetDataLowering>(TargetDataARM64::create(Ctx)); |
| -#endif |
| - llvm_unreachable("Unsupported target"); |
| +#define SUBZERO_TARGET(X) \ |
| + if (Target == Target_##X) \ |
| + return std::unique_ptr<TargetDataLowering>(TargetData##X::create(Ctx)); |
| +#include "llvm/Config/SZTargets.def" |
| + |
| + llvm_unreachable("Unsupported target data lowering"); |
| return nullptr; |
| } |