From: Borja F. <bor...@gm...> - 2013-06-24 23:43:18
|
Hello Stepan, Heh well, the first step on being able to compile avr-libc is to add full support for inline asm. Once that is finished we can then look at other places that may still have problems. The approach you're taking here looks sort of hacky :) but since i dont have a deep understanding on inline asm i cant think of other alternatives. I've been trying some code in gcc to see how this Q constraint works but i wasnt able to compile it, what's wrong in here? static char var; char foo() { char ret; asm("ld %0, %1": "=r" (ret) : "Q" (var)); return ret; } I expected this to work. Ok, having access to local vars using the Y+q addressing mode is important since most of them will be in frame indexes. I've noticed in your patch that you're checking in some places for the 'm' constraint instead of Q, i know you copied it from the arm backend, but be careful there in case things dont work as expected. One last thing, I dont like not allowing Y and Z being inflated. This has brought many problems in the past and blocks big size reduction optimizations, disabling this for this inline asm feature is a very expensive price that we can't pay. Hope this doesnt present any real issues for you. 2013/6/24 Stepan Dyatkovskiy <stp...@na...> > The patch. Forgot to attach it. > -Stepan. > > Stepan Dyatkovskiy wrote: > >> Hi Borja, >> >> > What happens in your example above when you use a real instruction like >> >>> for example LDD? Does it still use GPR8 regs? To me it's weird that if >>> you use a real instruction where operands are clearly defined in the td >>> file the instruction selector uses an invalid regclass. >>> >> >> There are two kinds of inline asm support in LLVM: >> 1. You just support all the constraints and pastes inline-asm contents >> as-is. That's why its still allowed to use names like "some_instr". >> 2. You may expand inline-asm strings set, or in another words just parse >> it onto set of instructions. In this case you have to implement >> TargetLowering::**ExpandInlineAsm method. >> I'd want to start it on this week though... >> >> But first we have to get avr-libc compilable (perhpas I read you >> thoughts ;-) ) >> >> Relative to memory constrains. I implemented initial version it can >> catch simplest cases (from test-case): >> >> @a = internal global i16 0, align 4 >> @b = internal global i16 0, align 4 >> define void @mem() { >> ;CHECK: some_instr Z, Y >> call void asm "some_instr $0, $1", "=*Q,=*Q"(i16* @a, i16* @b) >> ret void >> } >> >> The patch is attached. >> >> Its in my todo yet, to handle local variables. They could be emitted as >> Y+q expression. Hope to present this support tomorrow. So if 'a' and 'b' >> from example above would be local we could get "some_instr Y, Y+2" >> >> -Stepan. >> >> >> > |