[LLVMdev] Enhancing TableGen

David A. Greene greened at obbligato.org
Mon Oct 10 07:19:15 PDT 2011


Che-Liang Chiou <clchiou at gmail.com> writes:

>>> [Why NO abstractions (like `define foo(a, b, c)`)?]
>>> * Abstractions is probably worthy of, but I am not sure yet. I think
>>> we could wait until it is clear that we really need abstractions.
>>
>> I'm not sure what you mean by this abstraction.  Can you elaborate?
>>
>
> It is like C preprocessor style of #define foo(). You may define a
> function-like macro (creating abstraction of macros). I guess we will
> not like this idea since it adds extra looking-up efforts when we read
> a td file (we have to look up a macro function's definition as well as
> its instaniations).

I thought about something like this about a year ago.  It turns out we
already have it.  For example (adding a couple of nonexistant
operators):

class foo<int a, int b, int c> {
  int value = !add(!mul(a, b), c);
}

class bar<int v1, int v2, int v3> {
  int a = v1;
  int b = v2;
  int c = v3;
  int v = foo<v1, v2, v3>.value;
}

def BAZ : bar<2, 4, 6>;

                      -Dave




More information about the llvm-dev mailing list