fixes and changes the recently introduced 'alignas' to be 'align' (#12666)

* fixes and changes the recently introduced 'alignas' to be 'align'

* more improvements
This commit is contained in:
Andreas Rumpf 2019-11-15 20:24:14 +01:00 • committed by GitHub
commit 58f3e07b1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 50 additions and 44 deletions

View file

@ -479,8 +479,8 @@ proc localVarDecl(p: BProc; n: PNode): Rope =
if s.loc.k == locNone:
fillLoc(s.loc, locLocalVar, n, mangleLocalName(p, s), OnStack)
if s.kind == skLet: incl(s.loc.flags, lfNoDeepCopy)
if s.kind in {skLet, skVar} and s.alignment > 0:
result.addf("alignas($1) ", [rope(s.alignment)])
if s.kind in {skLet, skVar, skField, skForVar} and s.alignment > 0:
result.addf("NIM_ALIGN($1) ", [rope(s.alignment)])
result.add getTypeDesc(p.module, s.typ)
if s.constraint.isNil:
if sfRegister in s.flags: add(result, " register")
@ -533,7 +533,7 @@ proc assignGlobalVar(p: BProc, n: PNode) =
var td = getTypeDesc(p.module, s.loc.t)
if s.constraint.isNil:
if s.kind in {skLet, skVar, skField, skForVar} and s.alignment > 0:
decl.addf "alignas($1) ", [rope(s.alignment)]
decl.addf "NIM_ALIGN($1) ", [rope(s.alignment)]
if p.hcrOn: add(decl, "static ")
elif sfImportc in s.flags: add(decl, "extern ")
add(decl, td)
@ -1195,8 +1195,8 @@ proc genVarPrototype(m: BModule, n: PNode) =
declareThreadVar(m, sym, true)
else:
incl(m.declaredThings, sym.id)
if sym.alignment > 0:
m.s[cfsVars].addf "alignas($1) ", [rope(sym.alignment)]
if sym.kind in {skLet, skVar, skField, skForVar} and sym.alignment > 0:
m.s[cfsVars].addf "NIM_ALIGN($1) ", [rope(sym.alignment)]
add(m.s[cfsVars], if m.hcrOn: "static " else: "extern ")
add(m.s[cfsVars], getTypeDesc(m, sym.loc.t))
if m.hcrOn: add(m.s[cfsVars], "*")