Chris Lattner wrote:> On Tue, 22 Jun 2004, Vladimir Prus wrote: > > First, I attach two files -- LLVM asm and the asm for my target. The > > problem with assembler is: on line 171 it uses register gr2, which is > > copied from gr6 above, on line 161. The only predecessor of this basic > > block is jump on line 90. The problem is that gr6 is not initialized in > > the interval from the function entry till the jump. > > Okay, I see the problem. You need to tell the compiler that the > conditional branches are terminators. You're getting code that looks like > this: > > <LBB7> // // shortcirc_next.0.selectcont.selectcont > gr1 = gr1; > gr1 = gr1; > gr5 = 0; > gr2 - gr5; > if <>0 goto LBB11; > * gr2 = gr4; > * gr5 = gr1; > * gr6 = gr4; > * gr1 = gr1; > goto LBB8; > > I'm guessing that those copies are inserted by the register allocator, and > in particular, that is probably where gr6 is supposed to get it's value. > If you set the isTerminator flag on your 'if <>0 goto LBB11;' things will > probably magically start working for you, as the copies will be inserted > BEFORE the branch instead of after it.Hmm.. this is what I have in td file already: let isTerminator = 1 in def GOTO : Unknown<"goto">; def IFEQ : Unknown<"if =0 goto">; def IFNEQ : Unknown<"if <>0 goto">; ..... Should this work?> Also, if you haven't already, you might want to teach TargetInstrInfo > that '=' is a move instruction (implement isMoveInstr), so instructinos > like 'gr1 = gr1' will go away and you'll get coallescing. :)BTW, is it possible to set some instruction flag, instead of overriding a function? Something like: let isMove = 1 in def MOVE :..... ? - Volodya
On Wed, 23 Jun 2004, Vladimir Prus wrote:> Hmm.. this is what I have in td file already: > > let isTerminator = 1 in > def GOTO : Unknown<"goto">; > def IFEQ : Unknown<"if =0 goto">; > def IFNEQ : Unknown<"if <>0 goto">; > ..... > > Should this work?Nope, but try this: let isTerminator = 1 in { def GOTO : Unknown<"goto">; def IFEQ : Unknown<"if =0 goto">; def IFNEQ : Unknown<"if <>0 goto">; ..... } ... aka add {} Also, if you do 'tblgen target.td' it will spit out all of the records to stdout so you can visually inspect them.> > Also, if you haven't already, you might want to teach TargetInstrInfo > > that '=' is a move instruction (implement isMoveInstr), so instructinos > > like 'gr1 = gr1' will go away and you'll get coallescing. :) > > BTW, is it possible to set some instruction flag, instead of overriding a > function? Something like: > > let isMove = 1 in > def MOVE :.....That would make sense, but no not currently. :) If you wanted to teach it how to do that (similar to the isTerminator functionality), it would be a great patch. :) -Chris -- http://llvm.cs.uiuc.edu/ http://www.nondot.org/~sabre/Projects/
Chris Lattner wrote:> > let isTerminator = 1 in > > def GOTO : Unknown<"goto">; > > def IFEQ : Unknown<"if =0 goto">; > > def IFNEQ : Unknown<"if <>0 goto">; > > ..... > > > > Should this work? > > Nope, but try this: > > let isTerminator = 1 in { > def GOTO : Unknown<"goto">; > def IFEQ : Unknown<"if =0 goto">; > def IFNEQ : Unknown<"if <>0 goto">; > ..... > } > > ... aka add {}Uhm ;-) This change seems to fix things.> Also, if you do 'tblgen target.td' it will spit out all of the records > to stdout so you can visually inspect them. > > > > Also, if you haven't already, you might want to teach TargetInstrInfo > > > that '=' is a move instruction (implement isMoveInstr), so instructinos > > > like 'gr1 = gr1' will go away and you'll get coallescing. :) > > > > BTW, is it possible to set some instruction flag, instead of overriding a > > function? Something like: > > > > let isMove = 1 in > > def MOVE :..... > > That would make sense, but no not currently. :) If you wanted to teach > it how to do that (similar to the isTerminator functionality), it would be > a great patch. :)I'll probably look at the code. - Volodya
> > BTW, is it possible to set some instruction flag, instead of overriding a > > function? Something like: > > > > let isMove = 1 in > > def MOVE :..... > > That would make sense, but no not currently. :) If you wanted to teach > it how to do that (similar to the isTerminator functionality), it would be > a great patch. :)Actually, I just realized why this isn't possible: isMoveInstr is a predicate that returns three things: the boolean and the two registers being moved. The idea is that a move does not necessarily have to be a simple: 'X = Y' type of operation. On RISC machines, it might be an 'or' with the zero register. In particular, the method takes an instance of a MachineInstr because some instances of a particular opcode might be moves and some might not be. Sorry for leading you astray! -Chris -- http://llvm.cs.uiuc.edu/ http://www.nondot.org/~sabre/Projects/