Conversion of const llvm::MCExpr * to string

Hello,

I need the expression in string. How can i convert llvm::MCExpr * to string?

Please help.

Hi,

I need the expression in string. How can i convert llvm::MCExpr * to string?

Using MCExpr::print [1] with raw_string_ostream [2] should do what you want to do.

Cheers,
Florian

[1] http://llvm.org/doxygen/classllvm_1_1MCExpr.html#ae3067756d9df7843be2d25cedab37da4

[2] http://llvm.org/doxygen/classllvm_1_1raw__string__ostream.html

Thank you. I did as you mentioned. Now i am getting error because MAI is not defined in my code. I am adding the print statement in x86mccodeemitter.cpp.

string imm;
llvm::raw_string_ostream rso(imm);

MI.getOperand(4).getExpr()->print(rso, MAI);

getting error. What to do now?

Please help.