[LLVMdev] LLVM API: how to determine if the register is the status register

22 views
Skip to first unread message

Vadim Markovtsev

unread,
Dec 3, 2010, 3:56:18 AM12/3/10
to llv...@cs.uiuc.edu
Hello.

I've got the "unsigned int" register number. How one uses LLVM API to
determine if that register is the status register (e.g., ARM::CPSR) or
not? I know I can just compare the number with ARM::CPSR, but the code
becomes not universal. I gave up searching for the solution by myself...

Thanks.
_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Anton Korobeynikov

unread,
Dec 3, 2010, 6:58:00 AM12/3/10
to Vadim Markovtsev, llv...@cs.uiuc.edu
Hello,

> I've got the "unsigned int" register number. How one uses LLVM API to
> determine if that register is the status register (e.g., ARM::CPSR) or
> not? I know I can just compare the number with ARM::CPSR, but the code
> becomes not universal. I gave up searching for the solution by myself...

Why do you need this and what you're trying to do? There is no "status
register"
stuff inside LLVM, so there is no way to query for it. Also, reg
numbers exist only
inside particular target backend, thus you can always just compare
with target-specific reg.

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University

Anton Korobeynikov

unread,
Dec 8, 2010, 8:29:57 AM12/8/10
to Vadim Markovtsev, LLVM Developers Mailing List
Hello Vadim,

> CMP modifies the status register (e.g. CPSR in ARM). The question is, are
> there any modifications of the status register between those two compares.
> In other words, how to know if CPSR is changed in the code after the first
> CMP and before the second one.
After register allocation all the machine instructions have flags on
machine operands.
So, in this particular case you'll see that CPSR register is
implicitly defined by the first CMP.
After this you can look over def/kill/... flags on the operands of the
instruction to check whether
the register is used / changed in between.

Reply all
Reply to author
Forward
0 new messages