More questions on CompilerDriver.

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")]

2. Is there anyway to call a C++ hook from inside actions?
for example
(actions (case
          (not_empty "Wl,"), (append_cmd "$CALL(Myhook)" )))

Thanks in advance.
- Sanjiv

Hi Sanjiv,

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")'.

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.

BTW, I've implemented the OptionPreprocessor feature that we discussed
some time ago. See the documentation for details.

Mikhail Glushenkov wrote:

Hi Sanjiv,

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

Mikhail Glushenkov wrote:

> 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.

Hi Mikhail,
Did you get a chance to do something about this?

BTW, I've implemented the OptionPreprocessor feature that we discussed
some time ago. See the documentation for details.

is it a good idea to include something called "set_option"? For example if none of O0, O1, O2 or O3 are specified on the command line, We can just make O2 as default by using the set_option.

- Sanjiv

Hi Sanjiv,

Mikhail Glushenkov wrote:

> 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.

Hi Mikhail,
Did you get a chance to do something about this?

Sorry for the delay, will be ready Real Soon Now.
I've implemented 'forward_transformed_value', though.

BTW, I've implemented the OptionPreprocessor feature that we discussed
some time ago. See the documentation for details.

is it a good idea to include something called "set_option"? For example if
none of O0, O1, O2 or O3 are specified on the command line, We can just make
O2 as default by using the set_option.

Yes, I think it's a good idea.
For now you can simulate this with 'init' (enable -O2 by default and
make -O0 + -O2 = -O0, and -O2 + -O3 = -O3).

Mikhail Glushenkov a écrit :

Hi Sanjiv,

Mikhail Glushenkov wrote:

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.

Sorry, I didn't see this thread but I have a patch for that.

It's more a hack than really a new feature but that works well...

Index: LLVMCConfigurationEmitter.cpp