Skip to content

Commit

Permalink
software: fix broken OR1K inline assembly.
Browse files Browse the repository at this point in the history
The "K" constraint accepts a 16-bit immediate. It worked by accident
inside an inline function in GCC and Clang 3.5, but not newer
versions of Clang.
whitequark committed Mar 29, 2016
1 parent a0d75a0 commit 9fd5840
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions misoc/software/include/base/system.h
Original file line number Diff line number Diff line change
@@ -15,14 +15,14 @@ static inline unsigned long mfspr(unsigned long add)
{
unsigned long ret;

__asm__ __volatile__ ("l.mfspr %0,r0,%1" : "=r" (ret) : "K" (add));
__asm__ __volatile__ ("l.mfspr %0,%1,0" : "=r" (ret) : "r" (add));

return ret;
}

static inline void mtspr(unsigned long add, unsigned long val)
{
__asm__ __volatile__ ("l.mtspr r0,%1,%0" : : "K" (add), "r" (val));
__asm__ __volatile__ ("l.mtspr %0,%1,0" : : "r" (add), "r" (val));
}
#endif

0 comments on commit 9fd5840

Please sign in to comment.