Search code examples
compiler-constructionllvm

How can I make a label begin with a dot


As we know, a dot preceding a name is either an assembler directive or a local label. When I use my own LLVM backend to emit assembler, I find that all the labels are missing a preceding dot, which is different from other LLVM backends. Here are snippets.

.LBB1_2
    nop
    ba .LBB1_1
    nop
.LBB1_1:                                ! %if.then
    ld [%fp+-8], %i0
    add %i0, 1, %i0
    call test
    st %i0, [%fp+-8]
    ba .LBB1_2
    nop
.LBB1_2:                                ! %if.end
    ld [%fp+-8], %i0
    ret

mine is below:

JLT LBB1_2
    JMP LBB1_1
LBB1_1:                                 # %if.then
    LD.w r5, [sp]
    ADD r5, r5, #1
    ST.w [sp], r5
    LD r5, #test
    LJMP r5
    JMP LBB1_2
LBB1_2:                                 # %if.end
    LD.w r0, [sp]
    ADD sp, #8
    JMP lr

I have no idea what's going on and which part of my backend should be modified.


Solution

  • You'd need to specify PrivateLabelPrefix in your target's MCAsmInfo subclass. Note that PrivateLabelPrefix is set to .L by default for all ELF targets.