[LLVMdev] More questions on CompilerDriver.

Sanjiv Gupta sanjiv.gupta at microchip.com
Thu Nov 19 17:24:20 PST 2009


Mikhail Glushenkov wrote:
> Hi Sanjiv,
>
> On Thu, Nov 19, 2009 at 5:07 AM, Sanjiv Gupta
> <sanjiv.gupta at microchip.com> wrote:
>   
>> Hi Mikhail,
>>
>> I was trying to figure out how to do the following in compiler driver.
>>
>> 1.  mcc16 driver has a -p <device_name> option. Now from this device_name I
>> want to be able to construct a file name like "device_name.o" and pass that
>> to the linker. Unpack_values "p" gives me the device_name, but I do not know
>> how to add ".o" suffix to it.
>>
>> something like:
>> (not_empty "p"), [ (unpack_values "p"), (append_cmd ".o")]
>>     
>
> If the set of device_names is not large, you can work around this for
> now by creating a separate linker tool for each device_name (should be
> easy with inheritance) and then using OptionalEdges to choose the
> right "linker".
>
> A better solution is to add a  'forward_processed_value' action of the
> form '(forward_processed_value "opt-name" "HookName")'. Or maybe even
> '(forward_transformed_value "p" "$VAL.o")'.
>
>   
The set is large. But I think 'forward_transformed_value' should do.
Anywasy, we fixed this in our linker itself currently.
> Ideally, I'd like to make primitive actions composable, so that it'd
> possible to write something like '(forward (apply_hook "HookName"
> (get_value "p")))', but it's not especially fun to implement this on
> top of TableGen...
>
>   
>> 2. Is there anyway to call a C++ hook from inside actions?
>> for example
>> (actions (case
>>         (not_empty "Wl,"), (append_cmd "$CALL(Myhook)" )))
>>     
>
> Not yet, this is something I'm working on right now.
>   
That would be great. This is something we want to use for doing some 
special kind processing when -O1 or -O2 is specified.
> BTW, I've implemented the OptionPreprocessor feature that we discussed
> some time ago. See the documentation for details.
>
>   
Yes, I saw the document already. And that looks really good. Thanks for 
the same.


- Sanjiv





More information about the llvm-dev mailing list