[LLVMdev] cortex-m{3,4} special registers

Kurt Lidl
Sun, 28 Aug 2011 20:02:43 -0000

I was attempting to compile some code with a recent (r138716)
version of llvm/clang, targeting a cortex-m4 processor.

And I get an error like this:

CC:  sched_garbage.c
In file included from sched_garbage.c:43:
In file included from ./os_internal.h:48:
In file included from /p/nuttx/trunk/nuttx/include/sched.h:47:
In file included from /p/nuttx/trunk/nuttx/include/nuttx/sched.h:54:
In file included from /p/nuttx/trunk/nuttx/include/nuttx/irq.h:67:
In file included from /p/nuttx/trunk/nuttx/include/arch/irq.h:60:
/p/nuttx/trunk/nuttx/include/arch/armv7-m/irq.h:186:6: error: invalid operand
      for instruction
     "\tmrs    %0, primask\n"
     ^
<inline asm>:1:14: note: instantiated into assembly here
                mrs    r5, primask
                           ^

This appears to be due to llvm lacking support for the various
cortex-m{3,4} special registers.  ("primask", "faultmask",
etc)

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491c/ch05s13s01.html

Can someone tell me how I would go about adding support for these
special registers?

-Kurt