IRC logs for #openrisc Wednesday, 2014-08-06

--- Log opened Wed Aug 06 00:00:52 2014
poke53282Ok, it is mentioned in the discussions.00:13
poke53282Hmm, not sure if all points mentioned are valid.00:19
poke53282or fixable00:20
mor1kx[mor1kx] skristiansson pushed 1 new commit to master:
mor1kxmor1kx/master 3699dfb Stefan Kristiansson: cappuccino: move reading of rf port A to decode...05:32
poke53282stekern: I start to like musl05:33
poke53282But the number one distribution "sabotage" for musl is a little bit crazy.05:37
poke53282every program has its own /opt/ folder and everything else is symlinked05:38
poke53282"/usr" is symlinked to "."05:38
stekernI haven't looked closer at sabotage, and not alpine linux neither, which is another distro that use musl05:41
poke53282It's just funny that it works this way05:43
poke53282sabotage supports cross compiling with musl-cross05:44
poke53282unfortunately it uses 2 year old packages.05:45
stekernyeah, looking at them both, sabotage is probably more suited for us/your purposes05:45
poke53282not sure, most packages are outdated and fail in one or the other way with the toolchain.06:03
poke53282But he uses a lot of nice tricks which will help me.06:04
stekernok, I mostly meant between alpine and sabotage. adapting musl to your existing build setup is of course viable too06:06
poke53282My built system is also bad. Would be nicer to use a existing one sabotage-linux seems to be nice in principle but requires some work.06:10
stekerndarn... looks like I broke something with that last mor1kx commit...07:30
HeshamHi, can I use immediate constraint from inline assembly?08:31
LoneTechI'd imagine you could, for the relevant instructions. openrisc does not use the same mnemonic for add and add immediate, for instance08:32
Hesham"i", "I" "n" constraints are now allowed08:32
HeshamLoneTech: I mean from inline assembly, I want to use C variable value in an instruction like mfpsr from inline assembly08:59
ysionnea1your instruction uses immediate or register ?08:59
Heshamlets say I want to use l.mfspr %0, r0, %109:01
LoneTechHesham: variables for immediates are a no-go; they must be constants09:01
Hesham%0 is the C variable - destination09:02
LoneTechcompile time constants, even09:02
Hesham%1 is a another variable passed by value to the callee function, I want to use this value as immediate09:02
LoneTechthe thing is, immediates are encoded in the instruction itself, which is in the code section, which is read only09:04
ysionnea1asm volatile("l.mfspr %0, r0, %1" : "=r" (C_dest_var) : "r"(C_source_var) : );09:04
ysionnea1ah, %1 is an immediate09:04
LoneTechself modifying code is possible if your code memory is writable, but causes further complications with things like instruction cache and pipeline09:04
ysionnea1then what I said is wrong09:04
ysionnea1it can be done I think I remember someone talking to me about this kind of situation09:05
LoneTechso for mtspr/mfspr, use the base register if you want to select spr by variable09:05
ysionnea1you can write your function like f(int i) {}  but you will have to call it with constants like f(4) and not f(var)09:06
ysionnea1and gcc will just create as many "f" functions as calls with different values09:06
HeshamLoneTech: using the base register as constant right?09:06
ysionnea1I think it works if the function is inlined09:06
LoneTechyes, inlining could make compile time constants visible across a function call09:07
HeshamLoneTech: But what's the immediate constraints for OR1K case? I always got " error: impossible constraint in 'asm'" when trying using "i" or "I"09:08
Heshamysionnea1: It will be still passed by value in case of function calls, your method is right while using macros09:09
LoneTechHesham: specific instructions have immediates as specific operands, for instance l.mfspr rD, rS, imm copies spr rS|imm into rD09:09
ysionnea1it can work for functions as well, not just macro09:09
HeshamBut I do not wanna use macros, I need to use inline assembly09:10
LoneTechHesham: inline functions work similarly to macros, but allow full type declarations.09:10
HeshamLoneTech: Yes I know that, I want to get the value of 0xffffff for example, and place it in the immediate part from inline assembly09:11
LoneTechhuh? openrisc doesn't have that large immediates except for jump.09:12
HeshamI know that's just an example09:13
Heshamysionnea1: inline functions will pass this variable by value and allocate a work on the stack for it right?09:13
LoneTechHesham: no, inline functions are expanded in the calling function, and do not have their own stack frame, only compile time variable scope09:14
ysionnea1please try something like that
ysionnea1and call f(4)09:15
HeshamAnd is it guaranteed that the compiler will always inline it?09:15
HeshamOK I will check it09:15
ysionnea1well, not "r" but "I" or "i"09:15
ysionnea1I used the wrong constraint :)09:15
ysionnea1maybe better like that:
LoneTechHesham: not exactly. inline hints the compiler to do it inline, and with static inline there's no reason to add a non-inline version. whether it actually does inline may depend on the compiler and its settings09:17
Heshamysionnea1: That's exactly what I am doing09:17
HeshamWhen using "i" I got the error of : "error: impossible constraint in 'asm'"09:18
LoneTechtry chapter 6.39 of the gcc manual; GCC for instance does have an always_inline attribute09:18
Heshamysionnea1: I think that's something relates to binutils/gcc port ?09:18
ysionnea1I honestly didn't compile the code I just pasted09:19
ysionnea1but I'm sure what you want to do is possible, and with a function, I saw this kind of code used in the Linux port of OpenRISC09:19
HeshamLoneTech: It's not advised to use compiler specific attributes in my project09:20
ysionnea1I think stekern was showing me that code09:20
HeshamOK, thanks guys, I will have to try other methods and they how I can get it working.09:21
LoneTechHesham: then I have bad news - the entire constraint thing for asm is compiler specific (6.41, Extended Asm)09:21
HeshamLoneTech: Yes, that's my guess. That's why I asked here hoping that someone would give a little hint about possible constraints for or1k (hoping there is immediate one)09:23
HeshamI only use "=r" and "r" for now09:23
LoneTechwhile I don't recall verifying what constraint tag GCC uses for the immediates, as I told you openrisc defines operand type in every instruction. it's fully contrained when you choose instruction09:24
LoneTechand the compiler cannot move information from calls at runtime into immediates which are written at compile time09:25
LoneTechI'd suggest looking at how other pieces of code (linux, ecos, newlib) handle the task09:26
HeshamFor newlib, I believe macros are used, and not inline assembly.09:27
ysionnea1for spr they use macro and "K"09:27
ysionnea1but look at the function ...09:27
ysionnea1static inline, + "K"09:27
LoneTechysionnea1: thanks :)09:28
Heshamysionnea1: Thanks, that's should be the answer :)09:34
HeshamHowever I still got the same error when using "K" -> impossible constraint in 'asm'09:37
stekernHesham: then you are probably not calling the function with a constant09:38
Heshamstekern: Called with a constant09:41
Heshamstatic inline uint32_t _OR1K_mfspr(uint32_t reg)09:41
Hesham   uint32_t spr_value;09:41
Hesham  09:41
Hesham   __asm__ __volatile__ (09:41
Hesham     "l.mfspr  %0, r0, %1"09:41
Hesham     : "=r" (spr_value) : "K" (reg) : "memory");09:41
Hesham   09:41
Hesham   return spr_value;09:41
stekerncan you paste the code for the function and the code where you call it?09:41 some paste service09:41
stekernthat looks correct, but how do you call it?09:43
blueCmdthat paste looked quite neat. usually someone writes something in the middle of the paste09:44
blueCmdalmost modern art09:44
HeshamI think it will be clearer if I pushed the code to github and provide a link here, one sec..09:47
HeshamHere is the definition
HeshamThe error is not produced when calling it...09:53
Heshamstekern: And here is where it's called
HeshamIn the or1k_interrupt_disable function09:54
HeshamAn earlier warning at line 86 is:  warning: asm operand 1 probably doesn't match constraints09:56
Heshamin or1k-utility.h file09:56
stekernyes, but isn't it about the mtspr it complains, not the mfspr?09:59
stekernyou have the args the wrong way around10:00
stekernreg should be constant and value in a register10:00
stekernand you there's no output from mtspr, so you don't need to use the =r constraint10:01
Heshamstekern: Fixed, It's for _OR1K_mfspr where I got the error10:02
HeshamPlease refresh10:02
Hesham"rtems/score/or1k-utility.h:86:4: error: impossible constraint in 'asm"10:05
stekernnot that I think it's related, but why do you have a memory constraint in them?10:07
HeshamI got the error from the _OR1K_mfspr, when I replace "K" and put a "17" constant value instead of %1, the error goes away10:08
Heshamthe "memory" constraint is not the problem10:10
HeshamI think inline assembly does not recognize the "K" constraints10:11
stekernyeah, I didn't think it was.10:11
stekernwell, it does....10:11
stekernand the code in Linux works10:12
stekernare you compiling it without optimisations or something?10:13
HeshamI tried a bare-metal application and compiled it with "K" constraint with or1k-elf-gcc and it works10:16
stekernyou can of course use the register instead of the immediate too10:17
HeshamThe value of the register ?10:17
stekern__asm__ __volatile__ ("l.mfspr %0,%1,0" : "=r" (value) : "r" (reg));10:19
Heshamstekern: Feeling dump :) I miss that10:22
HeshamIt now compiles fine10:22
stekernbut I still wonder why it didn't work for you with the "K" constraint10:24
Hesham1Thanks stekern10:26
-!- Hesham1 is now known as Hesham10:27
juliusbHi all!11:52
juliusb2 things11:52
blueCmdjuliusb: hello11:53
juliusb1: it looks like there's another open source Verilog simulator now available, although not quite your usual open source project, but apparently it's pretty capable!
juliusbI read this article:   which I think the author doesn't quite understand why you would open source something11:53
juliusband second thing11:53
juliusbBasically a team at Cambridge are going to build a full on proper open source SoC11:54
juliusbbased on the RISC-V processor designs coming out of Berkeley11:54
blueCmdjuliusb: yes, you were on hackernews yesterday with that lowrisc thing11:54
juliusbThey've asked me to give them advice on various things11:54
juliusbwhich is fun, although basically so far all I've done is drink beer with them :)11:55
juliusbBut I think there might be room for an mor1kx in there, possibly11:55
juliusbwe'll see11:55
daliasstekern, the reason hesham's code didn't work with "K" is that the expression is not a constant12:04
daliasit may fold to a constant as an optimization. but it's not a constant expression.12:04
daliasthe way i usually handle this kind of constraint in inline asm is to give multiple options. e.g. for the syscall number on mips, i used "ir"(n) (immediate or register) and an instruction which would accept either. however this is hard to make work in the case at hand because the way they need to be used in the instruction mnemonic differs :/12:07
stekerndalias: yeah, I know. but I expect that the 'may fold' should happen in the code hesham pasted as long as optimization is turned on.12:11
stekernthat's why I asked if he's compiling with optimizations turned off12:11
stekern...if it's wise to rely on it, that's of course another question ;)12:11
daliasmy view is that any code that breaks under differences in optimization is a major bug12:12
dalias(another big example is code that relies on tail call optimization in order not to overflow the stack)12:12
daliasit's possible that the inlining doesn't happen at some -O levels other than 0, perhaps due to gcc mis-estimating the size cost of the asm block ?12:14
daliasi have a ridiculous example on x86....12:14
daliasthe function is:12:14
daliasreturn c ? x>>24 | x>>8&0xff00 | x<<8&0xff0000 | x<<24 : x;12:14
dalias(it's a conditional-bswap)12:15
daliasgcc inlines the conditional branch, but instead of putting an inline bswap in the caller, it puts a call instruction in the caller, calling a two-instruction function that's just bswap and ret...12:16
daliasand the call instruction is 5 bytes whereas the bswap is 2 bytes...12:16
daliasobviously something went wrong in gcc's representation of size cost (this is at -Os)12:16
Stman I have an urgent need for an orbd2a-ep4ce22 development kit, and OpenCores websites says it is no longer available ? Where can I buy this item quickly please ?12:18
StmanAny help would be really welcome.12:18
StmanAnyone with a reference from an equivalent development board ?12:18
stekerngcc's cost representation is a mystery to me, Peter Gavin was playing around with them a while back to make them represent mor1kx better. But he got worse performance out of it when he did that.12:18
stekernStman: there's a chinese guy that has made a similar board:,OpenRISC,0,535412:20
stekernjuliusb: cool, I saw your name on that lowrisc page ;)12:21
Stmanthank a lot stekern , I gonna have a look at it straigh away.12:24
mor1kx[mor1kx] skristiansson pushed 2 new commits to master:
mor1kxmor1kx/master 7ce6584 Stefan Kristiansson: cappuccino/decode: fix PIPELINED multiplier interlocks...14:24
mor1kxmor1kx/master 94d1a0b Stefan Kristiansson: cappuccino/fetch: latch rf address on bus_access_done...14:24
-!- ysionnea1 is now known as ysionneau14:26
poke53282stekern: With your patches to correct the linking error I get an error during compiling of musl:
poke53282Do you know anything about it? Otherwise I check my configure options. They are a little bit different to the musl-cross is using.16:23
stekernpoke53282: oh, crap...16:37
stekerndoes it work in musl-cross though?16:37
poke53282Good question. I don't know. But I can check.16:38
poke53282first check: BFD (GNU Binutils)
poke53282the only real difference is, that I use the --sysroot option.16:39
poke53282Wait, I will try. HAve to change for this I suppose16:40
poke53282in 5 minutes I know.16:46
stekernI'll test here too16:48
stekernyeah, I get that assert here too...16:51
poke53282Ok, but then the binutils version has changed?16:52
stekernno, I don't think I recompiled musl16:53
stekernI mean, it's not related to the version. It's related to my patch16:54
stekernwhich is why I haven't committed it anywhere yet, I'm not confident it doesn't brake other stuff16:54
stekern...which it obviously do :/16:55
poke53282this whole relocation and shared libs stuff is really complicated. That was a nice time during DOS. Even .com files ran without changes at different locations, thanks to the segment:offset addresses ;)17:00
stekernpoke53282: try this:
stekern is the part that has changed from the previous patch17:19
stekernif you could test this change too, it'd be great:
poke53282I use only one core so it will take a few minutes.17:25
stekernI'm in no hurry ;)17:27
poke53282At least, musl compiles now17:36
poke53282But as long as I don't see Guybrush Threepwood on my screen nothing is settled.17:37
stekernskip that second addition to the patch17:46
poke53282 /ld: BFD (GNU Binutils) assertion fail ../../../src/binutils/bfd/elf32-or1k.c:105417:47
poke53282collect2: error: ld returned 1 exit status17:47
poke53282because of this?17:47
stekernI couldn't recompile gcc with that, I need to take a second look at that17:47
poke53282got it one minute ago17:47
stekernyes, 1054 is in the that 'if'17:47
poke53282the toolchain compiles.18:35
poke53282the compilation went well. The error in scummvm is gone. But nothing happens when I start scummvm. not even "scummvm --help" works.19:03
poke53282I can still stop with CTRL+c19:03
poke53282the same is true for gcc. But here I it loads at least gcc --help works19:06
poke53282stekern: do you have a trivial example to check?19:08
poke53282C code I mean19:08
poke53282I don't implement l.swa correctly. So, maybe I should try qemu instead of jor1k.19:09
poke53282The native binutils were compiled with the old toolchain. Trying again if gcc works19:20
poke53282gcc works now19:23
poke53282but scummvm still doesn't work20:38
olofkHas anyone tried to get a copy of Tachyon-da? Would be fun to try it out20:49
olofkI asked for a copy now. Let's see what happens now21:00
olofkblueCmd: About to pull your bus converter stuff. Any changes lined up?21:07
blueCmdolofk: nope21:07
blueCmdolofk: thanks for merging21:07
olofkThey call me the lightning merger for my extreme swiftness in handling pull requests :)21:11
blueCmdolofk: Yes, that's a much deserved nickname! ;-)21:14
* rah emailed the people to apply for a position :-)21:41
rahI think it's (very highly) unlikely that they'll be interested but you never know..21:42
rahjuliusb: put in a good word for me? ;-)21:42
rah"that rah, he's a real code wizard, you should get him on board"21:43
--- Log closed Thu Aug 07 00:00:53 2014

Generated by 2.15.2 by Marius Gedminas - find it at!