Adding Flag Support in LLVM Backend

Hello.

I need to introduce a new flag in llc command like llc -mV to control the vectorization. How can I achieve this??

Please help.

Thank You

Hi,

You can find plenty of examples (including in the vectorizer) if you
grep for cl::opt.
The docs are here:
https://llvm.org/docs/CommandLine.html

Hope that helps,
Diana

Thank you.
I want to define a flag -optt-enabled in llc so i wrote following line in llc.cpp:

static cl::opt
OPPT(“oppt-enabled”, cl::desc(“Enables Optimization”), cl::init(false));

Now i want to check its value in x86isellwering.cpp
there i wrote:

if (OPPT)
{addRegisterClass(…)

}
but getting the error

use of undeclared identifier ‘OPPT’

Could someone tell me where i am mistaken? what else do i need to define.

Your cl::opt definition seems correct but the definition from llc.cpp is not visible in X86ISelLowring.cpp. The general practice is to define the cl::opt variable in the file you want to use it in. So you could try moving the definition to X86ISelLowering.cpp.