From 05b29919e1e7e33457af0363e4d67d1c83e0745a Mon Sep 17 00:00:00 2001 From: araq Date: Sat, 1 Jun 2024 19:00:23 +0200 Subject: [PATCH] WIP --- compiler/ccgstmts.nim | 6 +++--- lib/nimbase.h | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim index 345639d949..36d93b322a 100644 --- a/compiler/ccgstmts.nim +++ b/compiler/ccgstmts.nim @@ -1547,14 +1547,14 @@ proc genAsmStmt(p: BProc, t: PNode) = if whichPragma(i) == wAsmSyntax: asmSyntax = i[1].strVal - if asmSyntax != "" and + if asmSyntax != "" and not ( asmSyntax == "gcc" and hasGnuAsm in CC[p.config.cCompiler].props or asmSyntax == "vcc" and hasGnuAsm notin CC[p.config.cCompiler].props): localError( - p.config, t.info, + p.config, t.info, "Your compiler does not support the specified inline assembler") - + genAsmOrEmitStmt(p, t, isAsmStmt=true, s) # see bug #2362, "top level asm statements" seem to be a mis-feature # but even if we don't do this, the example in #2362 cannot possibly diff --git a/lib/nimbase.h b/lib/nimbase.h index 2204987db0..8b2efa2d7b 100644 --- a/lib/nimbase.h +++ b/lib/nimbase.h @@ -594,4 +594,30 @@ NIM_STATIC_ASSERT(sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8, "P #define NIM_NOALIAS __restrict /* __restrict is said to work for all the C(++) compilers out there that we support */ +#if defined(__GNUC__) +# define NIM_ERR_FLAG() /* nothing to declare: uses HW flag */ +# define NIM_ERR_JUMP(lab) __asm__ goto("jc %l0" \ + : \ + : \ + : \ + : lab) +# define NIM_ERR_SET() __asm__ volatile("stc" \ + : \ + : \ + : "cc" \ + ) + +# define NIM_ERR_CLEAR() __asm__ volatile("clc" \ + : \ + : \ + : "cc" \ + ) + +#else +# define NIM_ERR_FLAG() NIM_BOOL* nimErr_ +# define NIM_ERR_JUMP(lab) if (NIM_UNLIKELY(*nimErr_)) goto lab +# define NIM_ERR_CLEAR() *nimErr_ = NIM_FALSE +# define NIM_ERR_SET() *nimErr_ = NIM_TRUE +#endif /* __GNUC__ */ + #endif /* NIMBASE_H */