how to set -pre-ra-sched from code?

I've found that I need to set the -pre-RA-sched parameter when using tools like llc to get the kind of instruction scheduling I want.

However I'm normally generating and running code on the fly using the JIT, and can't figure out how to set the -pre-RA-sched option anywhere other than on the command line for the provided tools. So what code would I write (or where is the API?) to change the pre-regalloc instruction scheduler algorithm?

I've been unable to find this in the documentation or reading source code; a pointer would be really useful.

Thanks,

Andrew

I've found that I need to set the -pre-RA-sched parameter when using
tools like llc to get the kind of instruction scheduling I want.

However I'm normally generating and running code on the fly using the
JIT, and can't figure out how to set the -pre-RA-sched option anywhere
other than on the command line for the provided tools. So what code
would I write (or where is the API?) to change the pre-regalloc
instruction scheduler algorithm?

Does this thing below in TargetLowering help?

/// setSchedulingPreference - Specify the target scheduling preference.
  void setSchedulingPreference(SchedPreference Pref)

- Sanjiv

Sanjiv Gupta wrote:

I've found that I need to set the -pre-RA-sched parameter when using tools like llc to get the kind of instruction scheduling I want.

However I'm normally generating and running code on the fly using the JIT, and can't figure out how to set the -pre-RA-sched option anywhere other than on the command line for the provided tools. So what code would I write (or where is the API?) to change the pre-regalloc instruction scheduler algorithm?

Does this thing below in TargetLowering help?

/// setSchedulingPreference - Specify the target scheduling preference.
  void setSchedulingPreference(SchedPreference Pref)

Thanks! That doesn't look like what -pre-RA-sched eventually maps to, but it looks like the switch I want to change. Pardon my ignorance, but I have no idea how I'm supposed to get to a point where I can call this when all I have is a module and an execution engine.

Better yet, how would I go about figuring this out from the documentation? I'm having no luck at all finding these things.

Andrew

Sorry for responding to my own message but I would really appreciate some help with this.

Looking through the documentation again this morning I noticed that setSchedulingPreference is a protected method of LLVMTargetLowering, so it looks like it's not something I can call directly anyway. Furthermore it's only called from one place with a hard-coded value for any particular platform.

Andrew

Andrew Friedley wrote:

Hi Andrew,

Sorry for responding to my own message but I would really appreciate
some help with this.

Looking through the documentation again this morning I noticed that
setSchedulingPreference is a protected method of LLVMTargetLowering, so
it looks like it's not something I can call directly anyway.
Furthermore it's only called from one place with a hard-coded value for
any particular platform.

Andrew Friedley wrote:
  

Sanjiv Gupta wrote:
    

I've found that I need to set the -pre-RA-sched parameter when using
tools like llc to get the kind of instruction scheduling I want.

However I'm normally generating and running code on the fly using the
JIT, and can't figure out how to set the -pre-RA-sched option anywhere
other than on the command line for the provided tools. So what code
would I write (or where is the API?) to change the pre-regalloc
instruction scheduler algorithm?
        

Does this thing below in TargetLowering help?

/// setSchedulingPreference - Specify the target scheduling preference.
  void setSchedulingPreference(SchedPreference Pref)
      

Thanks! That doesn't look like what -pre-RA-sched eventually maps to,
but it looks like the switch I want to change. Pardon my ignorance, but
I have no idea how I'm supposed to get to a point where I can call this
when all I have is a module and an execution engine.

Better yet, how would I go about figuring this out from the
documentation? I'm having no luck at all finding these things.
    
You can programmatically pass command-line options using something like:

#include "llvm/Support/CommandLine.h"

int main()
{

    ...

    char *opts = {
        "dummy",
        "-fast-isel",
        "-fast-isel-verbose",
        "-pre-RA-sched=fast",
    };

    cl::ParseCommandLineOptions(4, opts, "Blah");

    ...
}

Could be that you need to include more headers, as I cut this piece from
my own more extensive code.

HTH,
Paul

Paul Melis wrote:

You can programmatically pass command-line options using something like:

#include "llvm/Support/CommandLine.h"

int main()
{

    ...

    char *opts = {
        "dummy",
        "-fast-isel",
        "-fast-isel-verbose",
        "-pre-RA-sched=fast", };

    cl::ParseCommandLineOptions(4, opts, "Blah");

    ...
}

Could be that you need to include more headers, as I cut this piece from
my own more extensive code.

Excellent, this really helps! Thanks!

Andrew