diff options
Diffstat (limited to 'llvm/unittests/tools/llvm-exegesis/Common/AssemblerUtils.h')
-rw-r--r-- | llvm/unittests/tools/llvm-exegesis/Common/AssemblerUtils.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/llvm/unittests/tools/llvm-exegesis/Common/AssemblerUtils.h b/llvm/unittests/tools/llvm-exegesis/Common/AssemblerUtils.h index 217ecc2a7b8..52133b4aee8 100644 --- a/llvm/unittests/tools/llvm-exegesis/Common/AssemblerUtils.h +++ b/llvm/unittests/tools/llvm-exegesis/Common/AssemblerUtils.h @@ -36,9 +36,16 @@ protected: } template <class... Bs> inline void Check(llvm::MCInst MCInst, Bs... Bytes) { - ExecutableFunction Function = (MCInst.getOpcode() == 0) - ? assembleToFunction({}) - : assembleToFunction({MCInst}); + CheckWithSetup(nullptr, {}, MCInst, Bytes...); + } + + template <class... Bs> + inline void CheckWithSetup(const ExegesisTarget *ET, + llvm::ArrayRef<unsigned> RegsToDef, + llvm::MCInst MCInst, Bs... Bytes) { + ExecutableFunction Function = + (MCInst.getOpcode() == 0) ? assembleToFunction(ET, RegsToDef, {}) + : assembleToFunction(ET, RegsToDef, {MCInst}); ASSERT_THAT(Function.getFunctionBytes().str(), testing::ElementsAre(Bytes...)); if (CanExecute) @@ -60,10 +67,13 @@ private: } ExecutableFunction - assembleToFunction(llvm::ArrayRef<llvm::MCInst> Instructions) { + assembleToFunction(const ExegesisTarget *ET, + llvm::ArrayRef<unsigned> RegsToDef, + llvm::ArrayRef<llvm::MCInst> Instructions) { llvm::SmallString<256> Buffer; llvm::raw_svector_ostream AsmStream(Buffer); - assembleToStream(createTargetMachine(), Instructions, AsmStream); + assembleToStream(ET, createTargetMachine(), RegsToDef, Instructions, + AsmStream); return ExecutableFunction(createTargetMachine(), getObjectFromBuffer(AsmStream.str())); } |