@@ -29,18 +29,18 @@ static constexpr const char ModuleID[] = "ExegesisInfoTest";
2929static constexpr const char FunctionID[] = " foo" ;
3030
3131static std::vector<llvm::MCInst>
32- generateSnippetSetupCode (const ExegesisTarget &ET ,
33- const llvm::MCSubtargetInfo * const MSI ,
34- llvm::ArrayRef<RegisterValue> RegisterInitialValues,
35- bool &IsSnippetSetupComplete) {
32+ generateSnippetSetupCode (const llvm::ArrayRef< unsigned > RegsToDef ,
33+ const ExegesisTarget &ET ,
34+ const llvm::LLVMTargetMachine &TM, bool &IsComplete) {
35+ IsComplete = true ;
3636 std::vector<llvm::MCInst> Result;
37- for (const RegisterValue &RV : RegisterInitialValues ) {
38- // Load a constant in the register.
39- const auto SetRegisterCode = ET.setRegTo (*MSI, RV. Register , RV. Value );
40- if (SetRegisterCode .empty ())
41- IsSnippetSetupComplete = false ;
42- Result.insert (Result.end (), SetRegisterCode .begin (), SetRegisterCode .end ());
43- }
37+ // for (const unsigned Reg : RegsToDef ) {
38+ // // Load a constant in the register.
39+ // const auto Code = ET.setRegToConstant(*TM.getMCSubtargetInfo(), Reg );
40+ // if (Code .empty())
41+ // IsComplete = false;
42+ // Result.insert(Result.end(), Code .begin(), Code .end());
43+ // }
4444 return Result;
4545}
4646
@@ -149,7 +149,7 @@ llvm::BitVector getFunctionReservedRegs(const llvm::TargetMachine &TM) {
149149void assembleToStream (const ExegesisTarget &ET,
150150 std::unique_ptr<llvm::LLVMTargetMachine> TM,
151151 llvm::ArrayRef<unsigned > LiveIns,
152- llvm::ArrayRef<RegisterValue> RegisterInitialValues ,
152+ llvm::ArrayRef<unsigned > RegsToDef ,
153153 llvm::ArrayRef<llvm::MCInst> Instructions,
154154 llvm::raw_pwrite_stream &AsmStream) {
155155 std::unique_ptr<llvm::LLVMContext> Context =
@@ -171,12 +171,13 @@ void assembleToStream(const ExegesisTarget &ET,
171171 MF.getRegInfo ().addLiveIn (Reg);
172172
173173 bool IsSnippetSetupComplete = false ;
174- std::vector<llvm::MCInst> Code =
175- generateSnippetSetupCode (ET, TM->getMCSubtargetInfo (),
176- RegisterInitialValues, IsSnippetSetupComplete);
177-
178- Code.insert (Code.end (), Instructions.begin (), Instructions.end ());
179-
174+ std::vector<llvm::MCInst> SnippetWithSetup =
175+ generateSnippetSetupCode (RegsToDef, ET, *TM, IsSnippetSetupComplete);
176+ if (!SnippetWithSetup.empty ()) {
177+ SnippetWithSetup.insert (SnippetWithSetup.end (), Instructions.begin (),
178+ Instructions.end ());
179+ Instructions = SnippetWithSetup;
180+ }
180181 // If the snippet setup is not complete, we disable liveliness tracking. This
181182 // means that we won't know what values are in the registers.
182183 if (!IsSnippetSetupComplete)
@@ -187,7 +188,7 @@ void assembleToStream(const ExegesisTarget &ET,
187188 MF.getRegInfo ().freezeReservedRegs (MF);
188189
189190 // Fill the MachineFunction from the instructions.
190- fillMachineFunction (MF, LiveIns, Code );
191+ fillMachineFunction (MF, LiveIns, Instructions );
191192
192193 // We create the pass manager, run the passes to populate AsmBuffer.
193194 llvm::MCContext &MCContext = MMI->getContext ();
0 commit comments