[PATCH] Darwin vararg parameters support in assembler macros

Jim Grosbach grosbach at apple.com
Fri Apr 25 10:43:27 PDT 2014


+Kevin, Tim


On Apr 25, 2014, at 5:00 AM, Stepan Dyatkovskiy <stpworld at narod.ru> wrote:

> Hi rafael, grosbach,
> 
> This patch implements experimental vararg support for Darwin.
> 
> It's experimental because I don't know how exaclty you want to treat such params. Perhaps you also would like to use number references for it $0, $1, .., $n.
> Patch adds dual representation of vararg parameter:
> - It is kept as single vararg string.
> - It also parsed onto tokens and stored in regular arguments collection.
> 
> Since don't know whether you need it at all, I've only activated GAS compatible rules.
> 
> Perhaps it would be dead Diff. But perhaps you will put your requests here, and I'll try to implement them ;-)
> 
> Here you can find:
> 1. Patch himself.
> 2. Test for darwin.
> 
> I also not sure about existing style. May be we refactor it a bit?
> 
> 1. Is it ok, we use structs everywhere? We could convert some of them into classes.
> 
> E.g.: MCAsmMacroParameter structure could be converted into:
> 
> 
>  class MCAsmMacroParameter {
>    StringRef Name;
>    MCAsmMacroArgument DefaultValue;
>    bool Required;
>  public:
>    void setName(StringRef Name) { this->Name = Name; }
>    StringRef getName() const { return Name; }
> 
>    void setDefaultValue(const MCAsmMacroArgument &V) { DefaultValue = V; }
>    const MCAsmMacroArgument &getDefaultValue() { return DefaultValue; }
> 
>    void setRequired(bool Required) { this->Required = Required; }
>    bool getRequired() const { return Required; }
> 
>    MCAsmMacroParameter() : Required(false) {}
>  };
> 
> 
> 
> You'll get bigger constructions (P.getName() instead of P.Name). But.. well I don't know why, my intuition just hints me to prefer classes.
> By now, I've kept structures.
> 
> 2. We could also use SmallVector instead of std::vector. Since collections are usually less than 8 items in size. I've kept std::vector in this diff.
> 
> 3. What do you think about "Substitution" term? In expandMacro we could use "ArrayRef<MCAsmMacroArgument> Substitutions" name then (instead of "ArrayRef<MCAsmMacroArgument> A").
> 
> So, if you agree, may be first we prepare refactor patch then?
> 
> http://reviews.llvm.org/D3507
> 
> Files:
>  lib/MC/MCParser/AsmParser.cpp
>  test/MC/AsmParser/macros-darwin-vararg.s
> <D3507.8837.patch>




More information about the llvm-commits mailing list