diff options
author | Hans de Goede <hdegoede@redhat.com> | 2016-04-07 14:47:42 +0200 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2016-06-28 11:53:43 +0200 |
commit | 2c2941fba8019780fa1bee92910acc093abc2ed2 (patch) | |
tree | d5f6977ca4f5cb37a3f12cbe1aab5b889f4da1d3 | |
parent | 0e8458bcc2436d49a137ea38d937c85b9618416d (diff) |
TGSI: Add tgsi_kernel_start to opencl.kernels metadata
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r-- | lib/Target/TGSI/TGSIAsmPrinter.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Target/TGSI/TGSIAsmPrinter.cpp b/lib/Target/TGSI/TGSIAsmPrinter.cpp index 713cabb6ddc..3585eb064c6 100644 --- a/lib/Target/TGSI/TGSIAsmPrinter.cpp +++ b/lib/Target/TGSI/TGSIAsmPrinter.cpp @@ -21,6 +21,7 @@ #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineInstr.h" +#include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" @@ -62,6 +63,7 @@ namespace { static const char *getRegisterName(unsigned RegNo); private: void EmitMCInstruction(const MCInst &mci); + void AddFunctionStartAddressMetadata(); }; } @@ -151,6 +153,14 @@ void TGSIAsmPrinter::EmitMCInstruction(const MCInst &mci) { instructionCount++; } +void TGSIAsmPrinter::AddFunctionStartAddressMetadata() { + Function *f = const_cast<Function *>(MF->getFunction()); + LLVMContext &ctx = f->getContext(); + auto *start = ConstantAsMetadata::get( + ConstantInt::get(Type::getInt32Ty(ctx), instructionCount)); + f->addMetadata("tgsi_kernel_start", *MDNode::get(ctx, { start })); +} + void TGSIAsmPrinter::EmitInstruction(const MachineInstr *mi) { MCInst mci; @@ -174,6 +184,7 @@ void TGSIAsmPrinter::EmitFunctionBodyStart() { MCInst mci; mci.setOpcode(TGSI::BGNSUB); + AddFunctionStartAddressMetadata(); EmitMCInstruction(mci); } |