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