summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ccgstmts.nim34
-rw-r--r--compiler/extccomp.nim5
-rw-r--r--compiler/nimrod.ini1
3 files changed, 29 insertions, 11 deletions
diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim
index 6f362a615..8115abc2f 100644
--- a/compiler/ccgstmts.nim
+++ b/compiler/ccgstmts.nim
@@ -814,31 +814,47 @@ proc genTry(p: BProc, t: PNode, d: var TLoc) =
     exprBlock(p, t.sons[i].sons[0], d)
   linefmt(p, cpsStmts, "if ($1.status != 0) #reraiseException();$n", safePoint)
 
-proc genAsmOrEmitStmt(p: BProc, t: PNode): PRope = 
-  for i in countup(0, sonsLen(t) - 1): 
+proc genAsmOrEmitStmt(p: BProc, t: PNode, isAsmStmt=false): PRope =
+  var res = ""
+  for i in countup(0, sonsLen(t) - 1):
     case t.sons[i].Kind
-    of nkStrLit..nkTripleStrLit: 
-      app(result, t.sons[i].strVal)
-    of nkSym: 
+    of nkStrLit..nkTripleStrLit:
+      res.add(t.sons[i].strVal)
+    of nkSym:
       var sym = t.sons[i].sym
       if sym.kind in {skProc, skIterator, skMethod}: 
         var a: TLoc
         initLocExpr(p, t.sons[i], a)
-        app(result, rdLoc(a))
-      else: 
+        res.add(rdLoc(a).ropeToStr)
+      else:
         var r = sym.loc.r
         if r == nil: 
           # if no name has already been given,
           # it doesn't matter much:
           r = mangleName(sym)
           sym.loc.r = r       # but be consequent!
-        app(result, r)
+        res.add(r.ropeToStr)
     else: InternalError(t.sons[i].info, "genAsmOrEmitStmt()")
+  
+  if isAsmStmt and hasGnuAsm in CC[ccompiler].props:
+    for x in splitLines(res):
+      var j = 0
+      while x[j] in {' ', '\t'}: inc(j)
+      if x[j] == ':' and x[j+1] == '"' or x[j] == '"':
+        # some clobber register list:
+        app(result, x); app(result, tnl)
+      elif x[j] != '\0':
+        # ignore empty lines
+        app(result, "\"")
+        app(result, x)
+        app(result, "\\n\"\n")
+  else:
+    result = res.toRope
 
 proc genAsmStmt(p: BProc, t: PNode) = 
   assert(t.kind == nkAsmStmt)
   genLineDir(p, t)
-  var s = genAsmOrEmitStmt(p, t)
+  var s = genAsmOrEmitStmt(p, t, isAsmStmt=true)
   lineF(p, cpsStmts, CC[ccompiler].asmStmtFrmt, [s])
 
 proc genEmit(p: BProc, t: PNode) = 
diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim
index efb8e5908..488ed18fb 100644
--- a/compiler/extccomp.nim
+++ b/compiler/extccomp.nim
@@ -22,7 +22,8 @@ type
     hasComputedGoto,          # CC has computed goto (GNU C extension)
     hasCpp,                   # CC is/contains a C++ compiler
     hasAssume,                # CC has __assume (Visual C extension)
-    hasGcGuard                # CC supports GC_GUARD to keep stack roots
+    hasGcGuard,               # CC supports GC_GUARD to keep stack roots
+    hasGnuAsm                 # CC's asm uses the absurd GNU assembler syntax
   TInfoCCProps* = set[TInfoCCProp]
   TInfoCC* = tuple[
     name: string,        # the short name of the compiler
@@ -72,7 +73,7 @@ compiler gcc:
     debug: "",
     pic: "-fPIC",
     asmStmtFrmt: "asm($1);$n",
-    props: {hasSwitchRange, hasComputedGoto, hasCpp, hasGcGuard})
+    props: {hasSwitchRange, hasComputedGoto, hasCpp, hasGcGuard, hasGnuAsm})
     
 compiler gpp:
   result = gcc()
diff --git a/compiler/nimrod.ini b/compiler/nimrod.ini
index 482fe63c9..22623993c 100644
--- a/compiler/nimrod.ini
+++ b/compiler/nimrod.ini
@@ -3,6 +3,7 @@ Name: "Nimrod"
 Version: "$version"
 OS: "windows;linux;macosx;solaris;freebsd;netbsd;openbsd"
 CPU: "i386;amd64;powerpc64;arm"  # ;sparc
+
 Authors: "Andreas Rumpf"
 Description: """This is the Nimrod Compiler. Nimrod is a new statically typed,
 imperative programming language, that supports procedural, functional, object