David Greene via llvm-dev
2021-Jul-12 16:32 UTC
[llvm-dev] MCAsmParser end-of-function API
AsmPrinter has an API emitFunctionBodyEnd that allows the target to emit whatever it needs at the end of a function. I cannot seem to find a similar interface in MCAsmParser/AsmParser. Did I miss it? I have the need to emit some tail padding at the end of a function, before the func_end label. I don't want to require users to emit the padding themselves when they hand-write asm. I suppose I could override doBeforeLabelEmit and look for the func_end label but that sems hacky and brittle. There's no guarantee the user would include such a label. -David
Fangrui Song via llvm-dev
2021-Jul-12 17:34 UTC
[llvm-dev] MCAsmParser end-of-function API
On 2021-07-12, David Greene via llvm-dev wrote:>AsmPrinter has an API emitFunctionBodyEnd that allows the target to emit >whatever it needs at the end of a function. I cannot seem to find a >similar interface in MCAsmParser/AsmParser. Did I miss it? I have the >need to emit some tail padding at the end of a function, before the >func_end label. I don't want to require users to emit the padding >themselves when they hand-write asm. I suppose I could override >doBeforeLabelEmit and look for the func_end label but that sems hacky >and brittle. There's no guarantee the user would include such a label. > > -DavidAsmParser::Run has the main workflow. You may customize the actions with MCTargetAsmParser::onEndOfFile. But may I ask why you need to emit something in (MC)AsmParser? AsmPrinter appears to be the more appropriate place. (Most targets only need to emit alignment at function start, so they don't need to care about padding at function end.)