5

I am working at a project about inline asm of LLVM, but I meet one problem about asm operands. For example, I have code like this:

int a;
int b;
asm("nop": "=r"(a), "r"(b), "g"(30));

I can get asm string "nop" using llvm::InlineAssembly::getAsmString () function, and I also can get constraints "r r imr" information using llvm::InlineAsm::ParseConstraints function and iterate the return value. But my question is I can not get asm operands information, especially asm operarands type(a is integer type, b is interger type, 30 is constant int).

So does anybody know is there any way to get asm operands information?

1 Answers1

0

In LLVM, InlineAsm is a subclass of Value, and the associated value is always of type pointer-to-function. The contents of that made-up function is the asm code itself.

So to get the types of the operands you analyze it just as with a pointer to function. You have a handy FunctionType *InlineAsm::getFunctionType() const that does half the work.

The rest is quite straightforward: Type * FunctionType::getReturnType() to get the output arguments and FunctionType::params() or similar to get the input arguments.

rodrigo
  • 94,151
  • 12
  • 143
  • 190