[LLVMdev] Sparc assembly syntax

Chris Lattner clattner at apple.com
Sun Aug 3 11:22:38 PDT 2008


On Aug 1, 2008, at 4:10 AM, Richard Pennington wrote:

> OK, so the next thing I found in Sparc world is that sparc-elf-as
> doesn't understand .bss as a directive for some reason.
>
> I modified the Sparc code generator to output .section ".bss" and that
> works just fine. My (temporary) solution is a hack, however:
>
> ==================================================================
> --- SparcAsmPrinter.cpp (revision 720)
> +++ SparcAsmPrinter.cpp (working copy)
> @@ -263,7 +263,7 @@
>            // FALL THROUGH
>          case GlobalValue::InternalLinkage:
>            if (C->isNullValue())
> -            SwitchToDataSection(".bss", I);
> +            SwitchToDataSection("\t.section\t\".bss\"", I);
>            else
>              SwitchToDataSection(".data", I);
>            break;
>
> My question is: What is the "right" way to do this? I looked at the  
> Mips
> code generator a little bit and it feels a little more modern. Is that
> correct?

As others mentioned, Anton is working on a significant cleanup to help  
unify the asm printers.  If you need to do this in the short term, I'd  
add an "isTargetELF()" method to the SparcSubtarget class, and have it  
autodetect it from the target triple as the x86 backend does.  With  
that, you can predicate the output based on whether the target is elf  
or not.

-Chris




More information about the llvm-dev mailing list