[PATCH][AsmParser][MC] Allow asm parser to emit elf header flags

Jack Carter Jack.Carter at imgtec.com
Thu Oct 3 15:45:39 PDT 2013


Ok, a more detailed response.
________________________________________
> From: Rafael EspĂ­ndola [rafael.espindola at gmail.com]
> Sent: Thursday, October 03, 2013 2:09 PM
> To: Jack Carter
> Cc: Vladimir Medic; llvm-commits at cs.uiuc.edu; Jim Grosbach; Rich Fuhler
> Subject: Re: [PATCH][AsmParser][MC] Allow asm parser to emit elf header flags
> 
> +  /// emitEndOfAsmFile -
> 
> Don't repeat the name of the asm function.

OK

> 
> +  enum MAFRelocationModelTy
> 
> Don't you want this in a more visible place? For example, llvm-objdump
> should be able to dump the flags in the ELF header, no?

No. Even though these look like ELF constructs, they are Mips assembler directives that do not automatically match directly. We are tracking the directives and will later may or may not translate them into one or more object format elements.

> 
> It looks like only MAF_RM_DEFAULT and MAF_RM_CPIC are used. Why? Can
> you just use a boolean?

Because these are the first of many. We cut down the patch to get folks to focus on the concept.

> 
> +  MipsMCAsmFlags()
> +    : Model(MAF_RM_DEFAULT){}
> 
> The formatting is wrong, please pass this via clang-format.
> 

OK

> 
> +/// emitEndOfAsmFile -
> 
> Don't duplicate the name.
> 

OK

> 
> +  if (MipsELFStreamer *MES = dyn_cast<MipsELFStreamer>(&OutStreamer))
> 
> Can't you use a cast? When would this be null?
> 

We thought this was the preferred way. We can change it, but why?

> 
> +#include "AsmParser/MipsAsmFlags.h"
>  #include "MCTargetDesc/MipsELFStreamer.h"
> 
> Wrong include order.
> 

OK

> > 
> +    else  if (RM != Reloc::Static) // Do nothing for Reloc::Static
> +      llvm_unreachable("Unsupported relocation model for e_flags");
> 

It can be an assert and we will change if, but why? Once again, we thought this was what we were suppose to do?

> This can be just an assert, no?
> 
> +  // For llvm-mc. Set a group of ELF header flags
> 
> This comment should be incorrect. Both llc and llvm-mc should use the
> same code path.
> 

This is what we really wanted a review for.

If this is not the correct way to implement this, Please let us know what is?

I implemented the Codegen method for this through the guidance of the list and am patterning the assembler's method after it. The Codegen stores the information about this information in a data structure that the assembler does not have access to. 

Remember, we have directives in the assembler code. We need to harvest it as we go along and at the end send information about it to the elf writer.

Any constructive guidance is appreciated. 
Thanks,

Jack

> 
> +#    .option pic0
> +#    .set mips16
> 
> no commented code.

OK






More information about the llvm-commits mailing list