| 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 // This file implements the skeleton of the TargetLowering class, | 10 // This file implements the skeleton of the TargetLowering class, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 TargetLowering *TargetLowering::createLowering(TargetArch Target, Cfg *Func) { | 72 TargetLowering *TargetLowering::createLowering(TargetArch Target, Cfg *Func) { |
| 73 #define SUBZERO_TARGET(X) \ | 73 #define SUBZERO_TARGET(X) \ |
| 74 if (Target == Target_##X) \ | 74 if (Target == Target_##X) \ |
| 75 return Target##X::create(Func); | 75 return Target##X::create(Func); |
| 76 #include "llvm/Config/SZTargets.def" | 76 #include "llvm/Config/SZTargets.def" |
| 77 | 77 |
| 78 Func->setError("Unsupported target"); | 78 Func->setError("Unsupported target"); |
| 79 return nullptr; | 79 return nullptr; |
| 80 } | 80 } |
| 81 | 81 |
| 82 TargetLowering::TargetLowering(Cfg *Func) | 82 TargetLowering::TargetLowering(Cfg *MyFunc) |
| 83 : Func(Func), Ctx(Func->getContext()), Context() {} | 83 : Func(MyFunc), Ctx(Func->getContext()), Context() {} |
| 84 | 84 |
| 85 std::unique_ptr<Assembler> TargetLowering::createAssembler(TargetArch Target, | 85 std::unique_ptr<Assembler> TargetLowering::createAssembler(TargetArch Target, |
| 86 Cfg *Func) { | 86 Cfg *Func) { |
| 87 #define SUBZERO_TARGET(X) \ | 87 #define SUBZERO_TARGET(X) \ |
| 88 if (Target == Target_##X) \ | 88 if (Target == Target_##X) \ |
| 89 return std::unique_ptr<Assembler>(new X::Assembler##X()); | 89 return std::unique_ptr<Assembler>(new X::Assembler##X()); |
| 90 #include "llvm/Config/SZTargets.def" | 90 #include "llvm/Config/SZTargets.def" |
| 91 | 91 |
| 92 Func->setError("Unsupported target assembler"); | 92 Func->setError("Unsupported target assembler"); |
| 93 return nullptr; | 93 return nullptr; |
| 94 } | 94 } |
| 95 | 95 |
| 96 void TargetLowering::doAddressOpt() { | 96 void TargetLowering::doAddressOpt() { |
| 97 if (llvm::isa<InstLoad>(*Context.getCur())) | 97 if (llvm::isa<InstLoad>(*Context.getCur())) |
| 98 doAddressOptLoad(); | 98 doAddressOptLoad(); |
| 99 else if (llvm::isa<InstStore>(*Context.getCur())) | 99 else if (llvm::isa<InstStore>(*Context.getCur())) |
| 100 doAddressOptStore(); | 100 doAddressOptStore(); |
| 101 Context.advanceCur(); | 101 Context.advanceCur(); |
| 102 Context.advanceNext(); | 102 Context.advanceNext(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void TargetLowering::doNopInsertion() { | 105 void TargetLowering::doNopInsertion() { |
| 106 Inst *I = Context.getCur(); | 106 Inst *I = Context.getCur(); |
| 107 bool ShouldSkip = llvm::isa<InstFakeUse>(I) || llvm::isa<InstFakeDef>(I) || | 107 bool ShouldSkip = llvm::isa<InstFakeUse>(I) || llvm::isa<InstFakeDef>(I) || |
| 108 llvm::isa<InstFakeKill>(I) || I->isRedundantAssign() || | 108 llvm::isa<InstFakeKill>(I) || I->isRedundantAssign() || |
| 109 I->isDeleted(); | 109 I->isDeleted(); |
| 110 if (!ShouldSkip) { | 110 if (!ShouldSkip) { |
| 111 int Probability = Ctx->getFlags().getNopProbabilityAsPercentage(); | 111 int Probability = Ctx->getFlags().getNopProbabilityAsPercentage(); |
| 112 for (int I = 0; I < Ctx->getFlags().getMaxNopsPerInstruction(); ++I) { | 112 for (int i = 0; i < Ctx->getFlags().getMaxNopsPerInstruction(); ++i) { |
| 113 randomlyInsertNop(Probability / 100.0); | 113 randomlyInsertNop(Probability / 100.0); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 // Lowers a single instruction according to the information in | 118 // Lowers a single instruction according to the information in |
| 119 // Context, by checking the Context.Cur instruction kind and calling | 119 // Context, by checking the Context.Cur instruction kind and calling |
| 120 // the appropriate lowering method. The lowering method should insert | 120 // the appropriate lowering method. The lowering method should insert |
| 121 // target instructions at the Cur.Next insertion point, and should not | 121 // target instructions at the Cur.Next insertion point, and should not |
| 122 // delete the Context.Cur instruction or advance Context.Cur. | 122 // delete the Context.Cur instruction or advance Context.Cur. |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 if (Target == Target_##X) \ | 564 if (Target == Target_##X) \ |
| 565 return TargetHeader##X::create(Ctx); | 565 return TargetHeader##X::create(Ctx); |
| 566 #include "llvm/Config/SZTargets.def" | 566 #include "llvm/Config/SZTargets.def" |
| 567 | 567 |
| 568 llvm::report_fatal_error("Unsupported target header lowering"); | 568 llvm::report_fatal_error("Unsupported target header lowering"); |
| 569 } | 569 } |
| 570 | 570 |
| 571 TargetHeaderLowering::~TargetHeaderLowering() = default; | 571 TargetHeaderLowering::~TargetHeaderLowering() = default; |
| 572 | 572 |
| 573 } // end of namespace Ice | 573 } // end of namespace Ice |
| OLD | NEW |