Commit 751e27ec by Jim Stichnoth

Subzero: Fix mid-line comments when using -asm-verbose .

The llvm-mc assembler for x86 uses '#' to start a mid-line comment, while arm32 uses '@'. Those characters cause syntax errors for the other architecture. There doesn't seem to be a common character for starting mid-line comments. However, the /* ... */ style comment works in both (all?) cases. (The '#' character at the start of a line, preceded by optional whitespace, starts a comment in both cases.) BUG= none TEST= ./pydir/szbuild_spec2k.py --force -v -O2 --filetype=asm --sz=--asm-verbose --target=arm32 TEST= ./pydir/szbuild_spec2k.py --force -v -O2 --filetype=asm --sz=--asm-verbose --target=x8632 R=kschimpf@google.com Review URL: https://codereview.chromium.org/1521863002 .
parent c628b680
...@@ -917,10 +917,10 @@ void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node, ...@@ -917,10 +917,10 @@ void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node,
const int32_t FrameOrStackReg = Func->getTarget()->getFrameOrStackReg(); const int32_t FrameOrStackReg = Func->getTarget()->getFrameOrStackReg();
if (IsLiveIn) { if (IsLiveIn) {
Live = &Liveness->getLiveIn(Node); Live = &Liveness->getLiveIn(Node);
Str << "\t\t\t\t# LiveIn="; Str << "\t\t\t\t/* LiveIn=";
} else { } else {
Live = &Liveness->getLiveOut(Node); Live = &Liveness->getLiveOut(Node);
Str << "\t\t\t\t# LiveOut="; Str << "\t\t\t\t/* LiveOut=";
} }
if (!Live->empty()) { if (!Live->empty()) {
CfgVector<Variable *> LiveRegs; CfgVector<Variable *> LiveRegs;
...@@ -951,7 +951,7 @@ void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node, ...@@ -951,7 +951,7 @@ void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node,
Var->emit(Func); Var->emit(Func);
} }
} }
Str << "\n"; Str << " */\n";
} }
/// Returns true if some text was emitted - in which case the caller definitely /// Returns true if some text was emitted - in which case the caller definitely
...@@ -981,11 +981,13 @@ bool emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr, ...@@ -981,11 +981,13 @@ bool emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr,
if (Printed) if (Printed)
Str << ","; Str << ",";
else else
Str << " \t@ END="; Str << " \t/* END=";
Var->emit(Func); Var->emit(Func);
Printed = true; Printed = true;
} }
} }
if (Printed)
Str << " */";
return Printed; return Printed;
} }
...@@ -1029,7 +1031,7 @@ void CfgNode::emit(Cfg *Func) const { ...@@ -1029,7 +1031,7 @@ void CfgNode::emit(Cfg *Func) const {
constexpr bool IsLiveIn = true; constexpr bool IsLiveIn = true;
emitRegisterUsage(Str, Func, this, IsLiveIn, LiveRegCount); emitRegisterUsage(Str, Func, this, IsLiveIn, LiveRegCount);
if (getInEdges().size()) { if (getInEdges().size()) {
Str << "\t\t\t\t# preds="; Str << "\t\t\t\t/* preds=";
bool First = true; bool First = true;
for (CfgNode *I : getInEdges()) { for (CfgNode *I : getInEdges()) {
if (!First) if (!First)
...@@ -1037,10 +1039,10 @@ void CfgNode::emit(Cfg *Func) const { ...@@ -1037,10 +1039,10 @@ void CfgNode::emit(Cfg *Func) const {
First = false; First = false;
Str << "$" << I->getName(); Str << "$" << I->getName();
} }
Str << "\n"; Str << " */\n";
} }
if (getLoopNestDepth()) { if (getLoopNestDepth()) {
Str << "\t\t\t\t# loop depth=" << getLoopNestDepth() << "\n"; Str << "\t\t\t\t/* loop depth=" << getLoopNestDepth() << " */\n";
} }
} }
......
...@@ -2623,7 +2623,7 @@ template <class Machine> void InstX86Nop<Machine>::emit(const Cfg *Func) const { ...@@ -2623,7 +2623,7 @@ template <class Machine> void InstX86Nop<Machine>::emit(const Cfg *Func) const {
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
// TODO: Emit the right code for each variant. // TODO: Emit the right code for each variant.
Str << "\t" Str << "\t"
"nop\t# variant = " << Variant; "nop\t/* variant = " << Variant << " */";
} }
template <class Machine> template <class Machine>
......
...@@ -6328,7 +6328,7 @@ void emitConstant( ...@@ -6328,7 +6328,7 @@ void emitConstant(
Str << ":\n\t" << Traits::AsmTag << "\t0x"; Str << ":\n\t" << Traits::AsmTag << "\t0x";
T Value = Const->getValue(); T Value = Const->getValue();
Str.write_hex(Traits::bitcastToUint64(Value)); Str.write_hex(Traits::bitcastToUint64(Value));
Str << "\t@" << Traits::TypeName << " " << Value << "\n"; Str << "\t/* " << Traits::TypeName << " " << Value << " */\n";
} }
template <typename T> void emitConstantPool(GlobalContext *Ctx) { template <typename T> void emitConstantPool(GlobalContext *Ctx) {
......
...@@ -810,8 +810,8 @@ void TargetDataX8632::emitConstantPool(GlobalContext *Ctx) { ...@@ -810,8 +810,8 @@ void TargetDataX8632::emitConstantPool(GlobalContext *Ctx) {
(size_t)CharsPrinted < llvm::array_lengthof(buf)); (size_t)CharsPrinted < llvm::array_lengthof(buf));
(void)CharsPrinted; // avoid warnings if asserts are disabled (void)CharsPrinted; // avoid warnings if asserts are disabled
Const->emitPoolLabel(Str, Ctx); Const->emitPoolLabel(Str, Ctx);
Str << ":\n\t" << T::AsmTag << "\t" << buf << "\t# " << T::TypeName << " " Str << ":\n\t" << T::AsmTag << "\t" << buf << "\t/* " << T::TypeName << " "
<< Value << "\n"; << Value << " */\n";
} }
} }
......
...@@ -796,8 +796,8 @@ void TargetDataX8664::emitConstantPool(GlobalContext *Ctx) { ...@@ -796,8 +796,8 @@ void TargetDataX8664::emitConstantPool(GlobalContext *Ctx) {
(size_t)CharsPrinted < llvm::array_lengthof(buf)); (size_t)CharsPrinted < llvm::array_lengthof(buf));
(void)CharsPrinted; // avoid warnings if asserts are disabled (void)CharsPrinted; // avoid warnings if asserts are disabled
Const->emitPoolLabel(Str, Ctx); Const->emitPoolLabel(Str, Ctx);
Str << ":\n\t" << T::AsmTag << "\t" << buf << "\t# " << T::TypeName << " " Str << ":\n\t" << T::AsmTag << "\t" << buf << "\t/* " << T::TypeName << " "
<< Value << "\n"; << Value << " */\n";
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
; REQUIRES: allow_dump ; REQUIRES: allow_dump
; Use filetype=asm because this currently depends on the # variant ; Use filetype=asm because this currently depends on the /* variant */
; assembler comment. ; assembler comment.
; RUN: %p2i -i %s --filetype=asm -a -sz-seed=1 -nop-insertion \ ; RUN: %p2i -i %s --filetype=asm -a -sz-seed=1 -nop-insertion \
...@@ -25,109 +25,109 @@ entry: ...@@ -25,109 +25,109 @@ entry:
ret <4 x i32> %res ret <4 x i32> %res
; PROB50-LABEL: mul_v4i32 ; PROB50-LABEL: mul_v4i32
; PROB50: nop # variant = 1 ; PROB50: nop /* variant = 1 */
; PROB50: subl $60, %esp ; PROB50: subl $60, %esp
; PROB50: nop # variant = 3 ; PROB50: nop /* variant = 3 */
; PROB50: movups %xmm0, 32(%esp) ; PROB50: movups %xmm0, 32(%esp)
; PROB50: movups %xmm1, 16(%esp) ; PROB50: movups %xmm1, 16(%esp)
; PROB50: movups 32(%esp), %xmm0 ; PROB50: movups 32(%esp), %xmm0
; PROB50: nop # variant = 1 ; PROB50: nop /* variant = 1 */
; PROB50: pshufd $49, 32(%esp), %xmm1 ; PROB50: pshufd $49, 32(%esp), %xmm1
; PROB50: nop # variant = 4 ; PROB50: nop /* variant = 4 */
; PROB50: pshufd $49, 16(%esp), %xmm2 ; PROB50: pshufd $49, 16(%esp), %xmm2
; PROB50: nop # variant = 1 ; PROB50: nop /* variant = 1 */
; PROB50: pmuludq 16(%esp), %xmm0 ; PROB50: pmuludq 16(%esp), %xmm0
; PROB50: pmuludq %xmm2, %xmm1 ; PROB50: pmuludq %xmm2, %xmm1
; PROB50: nop # variant = 0 ; PROB50: nop /* variant = 0 */
; PROB50: shufps $136, %xmm1, %xmm0 ; PROB50: shufps $136, %xmm1, %xmm0
; PROB50: nop # variant = 3 ; PROB50: nop /* variant = 3 */
; PROB50: pshufd $216, %xmm0, %xmm0 ; PROB50: pshufd $216, %xmm0, %xmm0
; PROB50: nop # variant = 1 ; PROB50: nop /* variant = 1 */
; PROB50: movups %xmm0, (%esp) ; PROB50: movups %xmm0, (%esp)
; PROB50: movups (%esp), %xmm0 ; PROB50: movups (%esp), %xmm0
; PROB50: addl $60, %esp ; PROB50: addl $60, %esp
; PROB50: ret ; PROB50: ret
; PROB90-LABEL: mul_v4i32 ; PROB90-LABEL: mul_v4i32
; PROB90: nop # variant = 1 ; PROB90: nop /* variant = 1 */
; PROB90: subl $60, %esp ; PROB90: subl $60, %esp
; PROB90: nop # variant = 3 ; PROB90: nop /* variant = 3 */
; PROB90: movups %xmm0, 32(%esp) ; PROB90: movups %xmm0, 32(%esp)
; PROB90: nop # variant = 4 ; PROB90: nop /* variant = 4 */
; PROB90: movups %xmm1, 16(%esp) ; PROB90: movups %xmm1, 16(%esp)
; PROB90: nop # variant = 1 ; PROB90: nop /* variant = 1 */
; PROB90: movups 32(%esp), %xmm0 ; PROB90: movups 32(%esp), %xmm0
; PROB90: nop # variant = 4 ; PROB90: nop /* variant = 4 */
; PROB90: pshufd $49, 32(%esp), %xmm1 ; PROB90: pshufd $49, 32(%esp), %xmm1
; PROB90: nop # variant = 1 ; PROB90: nop /* variant = 1 */
; PROB90: pshufd $49, 16(%esp), %xmm2 ; PROB90: pshufd $49, 16(%esp), %xmm2
; PROB90: nop # variant = 4 ; PROB90: nop /* variant = 4 */
; PROB90: pmuludq 16(%esp), %xmm0 ; PROB90: pmuludq 16(%esp), %xmm0
; PROB90: nop # variant = 2 ; PROB90: nop /* variant = 2 */
; PROB90: pmuludq %xmm2, %xmm1 ; PROB90: pmuludq %xmm2, %xmm1
; PROB90: shufps $136, %xmm1, %xmm0 ; PROB90: shufps $136, %xmm1, %xmm0
; PROB90: nop # variant = 1 ; PROB90: nop /* variant = 1 */
; PROB90: pshufd $216, %xmm0, %xmm0 ; PROB90: pshufd $216, %xmm0, %xmm0
; PROB90: movups %xmm0, (%esp) ; PROB90: movups %xmm0, (%esp)
; PROB90: nop # variant = 1 ; PROB90: nop /* variant = 1 */
; PROB90: movups (%esp), %xmm0 ; PROB90: movups (%esp), %xmm0
; PROB90: nop # variant = 0 ; PROB90: nop /* variant = 0 */
; PROB90: addl $60, %esp ; PROB90: addl $60, %esp
; PROB90: nop # variant = 0 ; PROB90: nop /* variant = 0 */
; PROB90: ret ; PROB90: ret
; PROB90: nop # variant = 4 ; PROB90: nop /* variant = 4 */
; MAXNOPS2-LABEL: mul_v4i32 ; MAXNOPS2-LABEL: mul_v4i32
; MAXNOPS2: nop # variant = 1 ; MAXNOPS2: nop /* variant = 1 */
; MAXNOPS2: nop # variant = 3 ; MAXNOPS2: nop /* variant = 3 */
; MAXNOPS2: subl $60, %esp ; MAXNOPS2: subl $60, %esp
; MAXNOPS2: movups %xmm0, 32(%esp) ; MAXNOPS2: movups %xmm0, 32(%esp)
; MAXNOPS2: nop # variant = 1 ; MAXNOPS2: nop /* variant = 1 */
; MAXNOPS2: nop # variant = 4 ; MAXNOPS2: nop /* variant = 4 */
; MAXNOPS2: movups %xmm1, 16(%esp) ; MAXNOPS2: movups %xmm1, 16(%esp)
; MAXNOPS2: nop # variant = 1 ; MAXNOPS2: nop /* variant = 1 */
; MAXNOPS2: movups 32(%esp), %xmm0 ; MAXNOPS2: movups 32(%esp), %xmm0
; MAXNOPS2: nop # variant = 0 ; MAXNOPS2: nop /* variant = 0 */
; MAXNOPS2: nop # variant = 3 ; MAXNOPS2: nop /* variant = 3 */
; MAXNOPS2: pshufd $49, 32(%esp), %xmm1 ; MAXNOPS2: pshufd $49, 32(%esp), %xmm1
; MAXNOPS2: nop # variant = 1 ; MAXNOPS2: nop /* variant = 1 */
; MAXNOPS2: pshufd $49, 16(%esp), %xmm2 ; MAXNOPS2: pshufd $49, 16(%esp), %xmm2
; MAXNOPS2: pmuludq 16(%esp), %xmm0 ; MAXNOPS2: pmuludq 16(%esp), %xmm0
; MAXNOPS2: pmuludq %xmm2, %xmm1 ; MAXNOPS2: pmuludq %xmm2, %xmm1
; MAXNOPS2: nop # variant = 0 ; MAXNOPS2: nop /* variant = 0 */
; MAXNOPS2: shufps $136, %xmm1, %xmm0 ; MAXNOPS2: shufps $136, %xmm1, %xmm0
; MAXNOPS2: nop # variant = 0 ; MAXNOPS2: nop /* variant = 0 */
; MAXNOPS2: nop # variant = 0 ; MAXNOPS2: nop /* variant = 0 */
; MAXNOPS2: pshufd $216, %xmm0, %xmm0 ; MAXNOPS2: pshufd $216, %xmm0, %xmm0
; MAXNOPS2: nop # variant = 1 ; MAXNOPS2: nop /* variant = 1 */
; MAXNOPS2: nop # variant = 3 ; MAXNOPS2: nop /* variant = 3 */
; MAXNOPS2: movups %xmm0, (%esp) ; MAXNOPS2: movups %xmm0, (%esp)
; MAXNOPS2: nop # variant = 3 ; MAXNOPS2: nop /* variant = 3 */
; MAXNOPS2: movups (%esp), %xmm0 ; MAXNOPS2: movups (%esp), %xmm0
; MAXNOPS2: addl $60, %esp ; MAXNOPS2: addl $60, %esp
; MAXNOPS2: nop # variant = 3 ; MAXNOPS2: nop /* variant = 3 */
; MAXNOPS2: ret ; MAXNOPS2: ret
; SANDBOX50-LABEL: mul_v4i32 ; SANDBOX50-LABEL: mul_v4i32
; SANDBOX50: nop # variant = 1 ; SANDBOX50: nop /* variant = 1 */
; SANDBOX50: subl $60, %esp ; SANDBOX50: subl $60, %esp
; SANDBOX50: nop # variant = 3 ; SANDBOX50: nop /* variant = 3 */
; SANDBOX50: movups %xmm0, 32(%esp) ; SANDBOX50: movups %xmm0, 32(%esp)
; SANDBOX50: movups %xmm1, 16(%esp) ; SANDBOX50: movups %xmm1, 16(%esp)
; SANDBOX50: movups 32(%esp), %xmm0 ; SANDBOX50: movups 32(%esp), %xmm0
; SANDBOX50: nop # variant = 1 ; SANDBOX50: nop /* variant = 1 */
; SANDBOX50: pshufd $49, 32(%esp), %xmm1 ; SANDBOX50: pshufd $49, 32(%esp), %xmm1
; SANDBOX50: nop # variant = 4 ; SANDBOX50: nop /* variant = 4 */
; SANDBOX50: pshufd $49, 16(%esp), %xmm2 ; SANDBOX50: pshufd $49, 16(%esp), %xmm2
; SANDBOX50: nop # variant = 1 ; SANDBOX50: nop /* variant = 1 */
; SANDBOX50: pmuludq 16(%esp), %xmm0 ; SANDBOX50: pmuludq 16(%esp), %xmm0
; SANDBOX50: pmuludq %xmm2, %xmm1 ; SANDBOX50: pmuludq %xmm2, %xmm1
; SANDBOX50: nop # variant = 0 ; SANDBOX50: nop /* variant = 0 */
; SANDBOX50: shufps $136, %xmm1, %xmm0 ; SANDBOX50: shufps $136, %xmm1, %xmm0
; SANDBOX50: nop # variant = 3 ; SANDBOX50: nop /* variant = 3 */
; SANDBOX50: pshufd $216, %xmm0, %xmm0 ; SANDBOX50: pshufd $216, %xmm0, %xmm0
; SANDBOX50: nop # variant = 1 ; SANDBOX50: nop /* variant = 1 */
; SANDBOX50: movups %xmm0, (%esp) ; SANDBOX50: movups %xmm0, (%esp)
; SANDBOX50: movups (%esp), %xmm0 ; SANDBOX50: movups (%esp), %xmm0
; SANDBOX50: addl $60, %esp ; SANDBOX50: addl $60, %esp
......
...@@ -110,24 +110,24 @@ entry: ...@@ -110,24 +110,24 @@ entry:
ret <4 x i32> %res ret <4 x i32> %res
; NOPINSERTION-LABEL: func1 ; NOPINSERTION-LABEL: func1
; NOPINSERTION: nop # variant = 1 ; NOPINSERTION: nop /* variant = 1 */
; NOPINSERTION: subl $60, %esp ; NOPINSERTION: subl $60, %esp
; NOPINSERTION: nop # variant = 3 ; NOPINSERTION: nop /* variant = 3 */
; NOPINSERTION: movups %xmm0, 32(%esp) ; NOPINSERTION: movups %xmm0, 32(%esp)
; NOPINSERTION: movups %xmm1, 16(%esp) ; NOPINSERTION: movups %xmm1, 16(%esp)
; NOPINSERTION: movups 32(%esp), %xmm0 ; NOPINSERTION: movups 32(%esp), %xmm0
; NOPINSERTION: nop # variant = 1 ; NOPINSERTION: nop /* variant = 1 */
; NOPINSERTION: pshufd $49, 32(%esp), %xmm1 ; NOPINSERTION: pshufd $49, 32(%esp), %xmm1
; NOPINSERTION: nop # variant = 4 ; NOPINSERTION: nop /* variant = 4 */
; NOPINSERTION: pshufd $49, 16(%esp), %xmm2 ; NOPINSERTION: pshufd $49, 16(%esp), %xmm2
; NOPINSERTION: nop # variant = 1 ; NOPINSERTION: nop /* variant = 1 */
; NOPINSERTION: pmuludq 16(%esp), %xmm0 ; NOPINSERTION: pmuludq 16(%esp), %xmm0
; NOPINSERTION: pmuludq %xmm2, %xmm1 ; NOPINSERTION: pmuludq %xmm2, %xmm1
; NOPINSERTION: nop # variant = 0 ; NOPINSERTION: nop /* variant = 0 */
; NOPINSERTION: shufps $136, %xmm1, %xmm0 ; NOPINSERTION: shufps $136, %xmm1, %xmm0
; NOPINSERTION: nop # variant = 3 ; NOPINSERTION: nop /* variant = 3 */
; NOPINSERTION: pshufd $216, %xmm0, %xmm0 ; NOPINSERTION: pshufd $216, %xmm0, %xmm0
; NOPINSERTION: nop # variant = 1 ; NOPINSERTION: nop /* variant = 1 */
; NOPINSERTION: movups %xmm0, (%esp) ; NOPINSERTION: movups %xmm0, (%esp)
; NOPINSERTION: movups (%esp), %xmm0 ; NOPINSERTION: movups (%esp), %xmm0
; NOPINSERTION: addl $60, %esp ; NOPINSERTION: addl $60, %esp
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment