Commit 0faec4c9 by Jan Voung

Rearrange emit vs emitIAS. Wait till function is done before dumping text.

Eventually, I wanted to have a flag "UseELFWriter" like: https://codereview.chromium.org/678533005/diff/120001/src/IceCfg.cpp Where the emit OStream would not have text, and only have binary. This refactor hopefully means fewer places to check for a flag to disable the text version of IAS, and be able to write binary. Otherwise, there are some text labels for branches that are still being dumped out. BUG=none R=stichnot@chromium.org Review URL: https://codereview.chromium.org/700263003
parent bfb410dd
...@@ -390,6 +390,22 @@ void Cfg::doBranchOpt() { ...@@ -390,6 +390,22 @@ void Cfg::doBranchOpt() {
// ======================== Dump routines ======================== // // ======================== Dump routines ======================== //
void Cfg::emitTextHeader(const IceString &MangledName) {
Ostream &Str = Ctx->getStrEmit();
Str << "\t.text\n";
if (Ctx->getFlags().FunctionSections)
Str << "\t.section\t.text." << MangledName << ",\"ax\",@progbits\n";
if (!getInternal() || Ctx->getFlags().DisableInternal) {
Str << "\t.globl\t" << MangledName << "\n";
Str << "\t.type\t" << MangledName << ",@function\n";
}
Str << "\t.p2align " << getTarget()->getBundleAlignLog2Bytes() << ",0x";
for (AsmCodeByte I : getTarget()->getNonExecBundlePadding())
Str.write_hex(I);
Str << "\n";
Str << MangledName << ":\n";
}
void Cfg::emit() { void Cfg::emit() {
TimerMarker T(TimerStack::TT_emit, this); TimerMarker T(TimerStack::TT_emit, this);
if (Ctx->getFlags().DecorateAsm) { if (Ctx->getFlags().DecorateAsm) {
...@@ -409,23 +425,23 @@ void Cfg::emit() { ...@@ -409,23 +425,23 @@ void Cfg::emit() {
<< " -o=MyObj.o" << " -o=MyObj.o"
<< "\n\n"; << "\n\n";
} }
Str << "\t.text\n";
IceString MangledName = getContext()->mangleName(getFunctionName()); IceString MangledName = getContext()->mangleName(getFunctionName());
if (Ctx->getFlags().FunctionSections) emitTextHeader(MangledName);
Str << "\t.section\t.text." << MangledName << ",\"ax\",@progbits\n";
if (!getInternal() || Ctx->getFlags().DisableInternal) {
Str << "\t.globl\t" << MangledName << "\n";
Str << "\t.type\t" << MangledName << ",@function\n";
}
Str << "\t.p2align " << getTarget()->getBundleAlignLog2Bytes() << ",0x";
for (AsmCodeByte I : getTarget()->getNonExecBundlePadding())
Str.write_hex(I);
Str << "\n";
for (CfgNode *Node : Nodes) for (CfgNode *Node : Nodes)
Node->emit(this); Node->emit(this);
Str << "\n"; Str << "\n";
} }
void Cfg::emitIAS() {
TimerMarker T(TimerStack::TT_emit, this);
assert(!Ctx->getFlags().DecorateAsm);
IceString MangledName = getContext()->mangleName(getFunctionName());
emitTextHeader(MangledName);
for (CfgNode *Node : Nodes)
Node->emitIAS(this);
getAssembler<Assembler>()->emitIASBytes(Ctx);
}
// Dumps the IR with an optional introductory message. // Dumps the IR with an optional introductory message.
void Cfg::dump(const IceString &Message) { void Cfg::dump(const IceString &Message) {
if (!Ctx->isVerbose()) if (!Ctx->isVerbose())
......
...@@ -94,9 +94,6 @@ public: ...@@ -94,9 +94,6 @@ public:
template <typename T> T *getAssembler() const { template <typename T> T *getAssembler() const {
return static_cast<T *>(TargetAssembler.get()); return static_cast<T *>(TargetAssembler.get());
} }
bool useIntegratedAssembler() const {
return getContext()->getFlags().UseIntegratedAssembler;
}
bool hasComputedFrame() const; bool hasComputedFrame() const;
bool getFocusedTiming() const { return FocusedTiming; } bool getFocusedTiming() const { return FocusedTiming; }
void setFocusedTiming() { FocusedTiming = true; } void setFocusedTiming() { FocusedTiming = true; }
...@@ -131,6 +128,8 @@ public: ...@@ -131,6 +128,8 @@ public:
const CfgNode *getCurrentNode() const { return CurrentNode; } const CfgNode *getCurrentNode() const { return CurrentNode; }
void emit(); void emit();
void emitIAS();
void emitTextHeader(const IceString &MangledName);
void dump(const IceString &Message = ""); void dump(const IceString &Message = "");
// Allocate data of type T using the per-Cfg allocator. // Allocate data of type T using the per-Cfg allocator.
......
...@@ -864,6 +864,24 @@ void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr, ...@@ -864,6 +864,24 @@ void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr,
} }
} }
void updateStats(Cfg *Func, const Inst *I) {
// Update emitted instruction count, plus fill/spill count for
// Variable operands without a physical register.
if (uint32_t Count = I->getEmitInstCount()) {
Func->getContext()->statsUpdateEmitted(Count);
if (Variable *Dest = I->getDest()) {
if (!Dest->hasReg())
Func->getContext()->statsUpdateFills();
}
for (SizeT S = 0; S < I->getSrcSize(); ++S) {
if (Variable *Src = llvm::dyn_cast<Variable>(I->getSrc(S))) {
if (!Src->hasReg())
Func->getContext()->statsUpdateSpills();
}
}
}
}
} // end of anonymous namespace } // end of anonymous namespace
void CfgNode::emit(Cfg *Func) const { void CfgNode::emit(Cfg *Func) const {
...@@ -871,14 +889,7 @@ void CfgNode::emit(Cfg *Func) const { ...@@ -871,14 +889,7 @@ void CfgNode::emit(Cfg *Func) const {
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
Liveness *Liveness = Func->getLiveness(); Liveness *Liveness = Func->getLiveness();
bool DecorateAsm = Liveness && Func->getContext()->getFlags().DecorateAsm; bool DecorateAsm = Liveness && Func->getContext()->getFlags().DecorateAsm;
if (Func->getEntryNode() == this) {
Str << Func->getContext()->mangleName(Func->getFunctionName()) << ":\n";
}
Str << getAsmName() << ":\n"; Str << getAsmName() << ":\n";
if (Func->useIntegratedAssembler()) {
Assembler *Asm = Func->getAssembler<Assembler>();
Asm->BindCfgNodeLabel(getIndex());
}
std::vector<SizeT> LiveRegCount(Func->getTarget()->getNumRegisters()); std::vector<SizeT> LiveRegCount(Func->getTarget()->getNumRegisters());
if (DecorateAsm) if (DecorateAsm)
emitRegisterUsage(Str, Func, this, true, LiveRegCount); emitRegisterUsage(Str, Func, this, true, LiveRegCount);
...@@ -899,34 +910,37 @@ void CfgNode::emit(Cfg *Func) const { ...@@ -899,34 +910,37 @@ void CfgNode::emit(Cfg *Func) const {
++LiveRegCount[Dest->getRegNum()]; ++LiveRegCount[Dest->getRegNum()];
continue; continue;
} }
if (Func->useIntegratedAssembler()) { I->emit(Func);
I->emitIAS(Func); if (DecorateAsm)
} else { emitLiveRangesEnded(Str, Func, I, LiveRegCount);
I->emit(Func); Str << "\n";
if (DecorateAsm) updateStats(Func, I);
emitLiveRangesEnded(Str, Func, I, LiveRegCount);
Str << "\n";
}
// Update emitted instruction count, plus fill/spill count for
// Variable operands without a physical register.
if (uint32_t Count = I->getEmitInstCount()) {
Func->getContext()->statsUpdateEmitted(Count);
if (Variable *Dest = I->getDest()) {
if (!Dest->hasReg())
Func->getContext()->statsUpdateFills();
}
for (SizeT S = 0; S < I->getSrcSize(); ++S) {
if (Variable *Src = llvm::dyn_cast<Variable>(I->getSrc(S))) {
if (!Src->hasReg())
Func->getContext()->statsUpdateSpills();
}
}
}
} }
if (DecorateAsm) if (DecorateAsm)
emitRegisterUsage(Str, Func, this, false, LiveRegCount); emitRegisterUsage(Str, Func, this, false, LiveRegCount);
} }
void CfgNode::emitIAS(Cfg *Func) const {
Func->setCurrentNode(this);
Assembler *Asm = Func->getAssembler<Assembler>();
Asm->BindCfgNodeLabel(getIndex());
for (InstPhi *Phi : Phis) {
if (Phi->isDeleted())
continue;
// Emitting a Phi instruction should cause an error.
Inst *Instr = Phi;
Instr->emitIAS(Func);
}
for (Inst *I : Insts) {
if (I->isDeleted())
continue;
if (I->isRedundantAssign())
continue;
I->emitIAS(Func);
updateStats(Func, I);
}
}
void CfgNode::dump(Cfg *Func) const { void CfgNode::dump(Cfg *Func) const {
Func->setCurrentNode(this); Func->setCurrentNode(this);
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
......
...@@ -82,6 +82,7 @@ public: ...@@ -82,6 +82,7 @@ public:
void contractIfEmpty(); void contractIfEmpty();
void doBranchOpt(const CfgNode *NextNode); void doBranchOpt(const CfgNode *NextNode);
void emit(Cfg *Func) const; void emit(Cfg *Func) const;
void emitIAS(Cfg *Func) const;
void dump(Cfg *Func) const; void dump(Cfg *Func) const;
private: private:
......
...@@ -342,84 +342,6 @@ InstX8632Xchg::InstX8632Xchg(Cfg *Func, Operand *Dest, Variable *Source) ...@@ -342,84 +342,6 @@ InstX8632Xchg::InstX8632Xchg(Cfg *Func, Operand *Dest, Variable *Source)
// ======================== Dump routines ======================== // // ======================== Dump routines ======================== //
namespace {
void emitIASBytes(const Cfg *Func, const x86::AssemblerX86 *Asm,
intptr_t StartPosition) {
GlobalContext *Ctx = Func->getContext();
Ostream &Str = Ctx->getStrEmit();
intptr_t EndPosition = Asm->GetPosition();
AssemblerFixup *LastFixup = Asm->GetLatestFixup(StartPosition);
if (!LastFixup) {
// The fixup doesn't apply to this current block.
for (intptr_t i = StartPosition; i < EndPosition; ++i) {
Str << "\t.byte 0x";
Str.write_hex(Asm->LoadBuffer<uint8_t>(i));
Str << "\n";
}
return;
}
intptr_t LastFixupLoc = LastFixup->position();
const intptr_t FixupSize = 4;
// The fixup does apply to this current block.
for (intptr_t i = StartPosition; i < LastFixupLoc; ++i) {
Str << "\t.byte 0x";
Str.write_hex(Asm->LoadBuffer<uint8_t>(i));
Str << "\n";
}
while (LastFixup) {
Str << "\t.long ";
const ConstantRelocatable *Reloc = LastFixup->value();
if (Reloc->getSuppressMangling())
Str << Reloc->getName();
else
Str << Ctx->mangleName(Reloc->getName());
if (LastFixup->value()->getOffset()) {
Str << " + " << LastFixup->value()->getOffset();
}
Str << "\n";
LastFixupLoc += FixupSize;
assert(LastFixupLoc <= EndPosition);
LastFixup = Asm->GetLatestFixup(LastFixupLoc);
// Assume multi-fixups are adjacent in the instruction encoding.
assert(!LastFixup || LastFixup->position() == LastFixupLoc);
}
for (intptr_t i = LastFixupLoc; i < EndPosition; ++i) {
Str << "\t.byte 0x";
Str.write_hex(Asm->LoadBuffer<uint8_t>(i));
Str << "\n";
}
}
void emitIASBytesBranch(const Cfg *Func, const x86::AssemblerX86 *Asm,
intptr_t StartPosition, const x86::Label *Label,
const IceString &LabelName, bool Near) {
// If this is a backward branch (label is bound), we're good and know
// the offset. If this is a forward branch, then we can't actually emit
// the thing as text in a streaming manner, because the fixup hasn't
// happened yet. Instead, emit .long ($BranchLabel) - (. + 4), in that
// case and let the external assembler take care of that fixup.
if (Label->IsBound()) {
emitIASBytes(Func, Asm, StartPosition);
return;
}
const intptr_t FwdBranchSize = Near ? 1 : 4;
const IceString FwdBranchDirective = Near ? ".byte" : ".long";
Ostream &Str = Func->getContext()->getStrEmit();
intptr_t EndPosition = Asm->GetPosition();
assert(EndPosition - StartPosition > FwdBranchSize);
for (intptr_t i = StartPosition; i < EndPosition - FwdBranchSize; ++i) {
Str << "\t.byte 0x";
Str.write_hex(Asm->LoadBuffer<uint8_t>(i));
Str << "\n";
}
Str << "\t" << FwdBranchDirective << " " << LabelName << " - (. + "
<< FwdBranchSize << ")\n";
return;
}
} // end of anonymous namespace
void InstX8632::dump(const Cfg *Func) const { void InstX8632::dump(const Cfg *Func) const {
Ostream &Str = Func->getContext()->getStrDump(); Ostream &Str = Func->getContext()->getStrDump();
Str << "[X8632] "; Str << "[X8632] ";
...@@ -434,10 +356,6 @@ void InstX8632Label::emit(const Cfg *Func) const { ...@@ -434,10 +356,6 @@ void InstX8632Label::emit(const Cfg *Func) const {
void InstX8632Label::emitIAS(const Cfg *Func) const { void InstX8632Label::emitIAS(const Cfg *Func) const {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
Asm->BindLocalLabel(Number); Asm->BindLocalLabel(Number);
// TODO(jvoung): remove the the textual label once forward branch
// fixups are used (and text assembler is not used).
Ostream &Str = Func->getContext()->getStrEmit();
Str << getName(Func) << ":\n";
} }
void InstX8632Label::dump(const Cfg *Func) const { void InstX8632Label::dump(const Cfg *Func) const {
...@@ -471,7 +389,6 @@ void InstX8632Br::emit(const Cfg *Func) const { ...@@ -471,7 +389,6 @@ void InstX8632Br::emit(const Cfg *Func) const {
void InstX8632Br::emitIAS(const Cfg *Func) const { void InstX8632Br::emitIAS(const Cfg *Func) const {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
if (Label) { if (Label) {
x86::Label *L = Asm->GetOrCreateLocalLabel(Label->getNumber()); x86::Label *L = Asm->GetOrCreateLocalLabel(Label->getNumber());
// In all these cases, local Labels should only be used for Near. // In all these cases, local Labels should only be used for Near.
...@@ -481,7 +398,6 @@ void InstX8632Br::emitIAS(const Cfg *Func) const { ...@@ -481,7 +398,6 @@ void InstX8632Br::emitIAS(const Cfg *Func) const {
} else { } else {
Asm->j(Condition, L, Near); Asm->j(Condition, L, Near);
} }
emitIASBytesBranch(Func, Asm, StartPosition, L, Label->getName(Func), Near);
} else { } else {
// Pessimistically assume it's far. This only affects Labels that // Pessimistically assume it's far. This only affects Labels that
// are not Bound. // are not Bound.
...@@ -491,20 +407,13 @@ void InstX8632Br::emitIAS(const Cfg *Func) const { ...@@ -491,20 +407,13 @@ void InstX8632Br::emitIAS(const Cfg *Func) const {
Asm->GetOrCreateCfgNodeLabel(getTargetFalse()->getIndex()); Asm->GetOrCreateCfgNodeLabel(getTargetFalse()->getIndex());
assert(!getTargetTrue()); assert(!getTargetTrue());
Asm->jmp(L, Near); Asm->jmp(L, Near);
emitIASBytesBranch(Func, Asm, StartPosition, L,
getTargetFalse()->getAsmName(), Near);
} else { } else {
x86::Label *L = Asm->GetOrCreateCfgNodeLabel(getTargetTrue()->getIndex()); x86::Label *L = Asm->GetOrCreateCfgNodeLabel(getTargetTrue()->getIndex());
Asm->j(Condition, L, Near); Asm->j(Condition, L, Near);
emitIASBytesBranch(Func, Asm, StartPosition, L,
getTargetTrue()->getAsmName(), Near);
StartPosition = Asm->GetPosition();
if (getTargetFalse()) { if (getTargetFalse()) {
x86::Label *L2 = x86::Label *L2 =
Asm->GetOrCreateCfgNodeLabel(getTargetFalse()->getIndex()); Asm->GetOrCreateCfgNodeLabel(getTargetFalse()->getIndex());
Asm->jmp(L2, Near); Asm->jmp(L2, Near);
emitIASBytesBranch(Func, Asm, StartPosition, L2,
getTargetFalse()->getAsmName(), Near);
} }
} }
} }
...@@ -549,9 +458,7 @@ void InstX8632Call::emit(const Cfg *Func) const { ...@@ -549,9 +458,7 @@ void InstX8632Call::emit(const Cfg *Func) const {
void InstX8632Call::emitIAS(const Cfg *Func) const { void InstX8632Call::emitIAS(const Cfg *Func) const {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
Operand *Target = getCallTarget(); Operand *Target = getCallTarget();
bool NeedsFallback = false;
if (const auto Var = llvm::dyn_cast<Variable>(Target)) { if (const auto Var = llvm::dyn_cast<Variable>(Target)) {
if (Var->hasReg()) { if (Var->hasReg()) {
Asm->call(RegX8632::getEncodedGPR(Var->getRegNum())); Asm->call(RegX8632::getEncodedGPR(Var->getRegNum()));
...@@ -565,7 +472,6 @@ void InstX8632Call::emitIAS(const Cfg *Func) const { ...@@ -565,7 +472,6 @@ void InstX8632Call::emitIAS(const Cfg *Func) const {
} else if (const auto CR = llvm::dyn_cast<ConstantRelocatable>(Target)) { } else if (const auto CR = llvm::dyn_cast<ConstantRelocatable>(Target)) {
assert(CR->getOffset() == 0 && "We only support calling a function"); assert(CR->getOffset() == 0 && "We only support calling a function");
Asm->call(CR); Asm->call(CR);
NeedsFallback = true;
} else if (const auto Imm = llvm::dyn_cast<ConstantInteger32>(Target)) { } else if (const auto Imm = llvm::dyn_cast<ConstantInteger32>(Target)) {
// NaCl trampoline calls refer to an address within the sandbox directly. // NaCl trampoline calls refer to an address within the sandbox directly.
// This is usually only needed for non-IRT builds and otherwise not // This is usually only needed for non-IRT builds and otherwise not
...@@ -579,18 +485,6 @@ void InstX8632Call::emitIAS(const Cfg *Func) const { ...@@ -579,18 +485,6 @@ void InstX8632Call::emitIAS(const Cfg *Func) const {
} else { } else {
llvm_unreachable("Unexpected operand type"); llvm_unreachable("Unexpected operand type");
} }
if (NeedsFallback) {
// TODO(jvoung): The ".long sym" hack doesn't work, since we need
// a pc-rel relocation and not an absolute relocation.
//
// Still, we have at least filled the assembler buffer so that the
// instruction sizes/positions are correct for jumps.
// For now, fall back to the regular .s emission, after filling the buffer.
emit(Func);
Func->getContext()->getStrEmit() << "\n";
} else {
emitIASBytes(Func, Asm, StartPosition);
}
Func->getTarget()->resetStackAdjustment(); Func->getTarget()->resetStackAdjustment();
} }
...@@ -628,7 +522,6 @@ void emitTwoAddress(const char *Opcode, const Inst *Inst, const Cfg *Func, ...@@ -628,7 +522,6 @@ void emitTwoAddress(const char *Opcode, const Inst *Inst, const Cfg *Func,
void emitIASOpTyGPR(const Cfg *Func, Type Ty, const Operand *Op, void emitIASOpTyGPR(const Cfg *Func, Type Ty, const Operand *Op,
const x86::AssemblerX86::GPREmitterOneOp &Emitter) { const x86::AssemblerX86::GPREmitterOneOp &Emitter) {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
if (const auto Var = llvm::dyn_cast<Variable>(Op)) { if (const auto Var = llvm::dyn_cast<Variable>(Op)) {
if (Var->hasReg()) { if (Var->hasReg()) {
// We cheat a little and use GPRRegister even for byte operations. // We cheat a little and use GPRRegister even for byte operations.
...@@ -646,7 +539,6 @@ void emitIASOpTyGPR(const Cfg *Func, Type Ty, const Operand *Op, ...@@ -646,7 +539,6 @@ void emitIASOpTyGPR(const Cfg *Func, Type Ty, const Operand *Op,
} else { } else {
llvm_unreachable("Unexpected operand type"); llvm_unreachable("Unexpected operand type");
} }
emitIASBytes(Func, Asm, StartPosition);
} }
template <bool VarCanBeByte, bool SrcCanBeByte> template <bool VarCanBeByte, bool SrcCanBeByte>
...@@ -654,7 +546,6 @@ void emitIASRegOpTyGPR(const Cfg *Func, Type Ty, const Variable *Var, ...@@ -654,7 +546,6 @@ void emitIASRegOpTyGPR(const Cfg *Func, Type Ty, const Variable *Var,
const Operand *Src, const Operand *Src,
const x86::AssemblerX86::GPREmitterRegOp &Emitter) { const x86::AssemblerX86::GPREmitterRegOp &Emitter) {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
assert(Var->hasReg()); assert(Var->hasReg());
// We cheat a little and use GPRRegister even for byte operations. // We cheat a little and use GPRRegister even for byte operations.
RegX8632::GPRRegister VarReg = RegX8632::GPRRegister VarReg =
...@@ -686,14 +577,12 @@ void emitIASRegOpTyGPR(const Cfg *Func, Type Ty, const Variable *Var, ...@@ -686,14 +577,12 @@ void emitIASRegOpTyGPR(const Cfg *Func, Type Ty, const Variable *Var,
} else { } else {
llvm_unreachable("Unexpected operand type"); llvm_unreachable("Unexpected operand type");
} }
emitIASBytes(Func, Asm, StartPosition);
} }
void emitIASAddrOpTyGPR(const Cfg *Func, Type Ty, const x86::Address &Addr, void emitIASAddrOpTyGPR(const Cfg *Func, Type Ty, const x86::Address &Addr,
const Operand *Src, const Operand *Src,
const x86::AssemblerX86::GPREmitterAddrOp &Emitter) { const x86::AssemblerX86::GPREmitterAddrOp &Emitter) {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
// Src can only be Reg or Immediate. // Src can only be Reg or Immediate.
if (const auto SrcVar = llvm::dyn_cast<Variable>(Src)) { if (const auto SrcVar = llvm::dyn_cast<Variable>(Src)) {
assert(SrcVar->hasReg()); assert(SrcVar->hasReg());
...@@ -709,7 +598,6 @@ void emitIASAddrOpTyGPR(const Cfg *Func, Type Ty, const x86::Address &Addr, ...@@ -709,7 +598,6 @@ void emitIASAddrOpTyGPR(const Cfg *Func, Type Ty, const x86::Address &Addr,
} else { } else {
llvm_unreachable("Unexpected operand type"); llvm_unreachable("Unexpected operand type");
} }
emitIASBytes(Func, Asm, StartPosition);
} }
void emitIASAsAddrOpTyGPR(const Cfg *Func, Type Ty, const Operand *Op0, void emitIASAsAddrOpTyGPR(const Cfg *Func, Type Ty, const Operand *Op0,
...@@ -735,7 +623,6 @@ void emitIASGPRShift(const Cfg *Func, Type Ty, const Variable *Var, ...@@ -735,7 +623,6 @@ void emitIASGPRShift(const Cfg *Func, Type Ty, const Variable *Var,
const Operand *Src, const Operand *Src,
const x86::AssemblerX86::GPREmitterShiftOp &Emitter) { const x86::AssemblerX86::GPREmitterShiftOp &Emitter) {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
// Technically, the Dest Var can be mem as well, but we only use Reg. // Technically, the Dest Var can be mem as well, but we only use Reg.
// We can extend this to check Dest if we decide to use that form. // We can extend this to check Dest if we decide to use that form.
assert(Var->hasReg()); assert(Var->hasReg());
...@@ -754,14 +641,12 @@ void emitIASGPRShift(const Cfg *Func, Type Ty, const Variable *Var, ...@@ -754,14 +641,12 @@ void emitIASGPRShift(const Cfg *Func, Type Ty, const Variable *Var,
} else { } else {
llvm_unreachable("Unexpected operand type"); llvm_unreachable("Unexpected operand type");
} }
emitIASBytes(Func, Asm, StartPosition);
} }
void emitIASGPRShiftDouble(const Cfg *Func, const Variable *Dest, void emitIASGPRShiftDouble(const Cfg *Func, const Variable *Dest,
const Operand *Src1Op, const Operand *Src2Op, const Operand *Src1Op, const Operand *Src2Op,
const x86::AssemblerX86::GPREmitterShiftD &Emitter) { const x86::AssemblerX86::GPREmitterShiftD &Emitter) {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
// Dest can be reg or mem, but we only use the reg variant. // Dest can be reg or mem, but we only use the reg variant.
assert(Dest->hasReg()); assert(Dest->hasReg());
RegX8632::GPRRegister DestReg = RegX8632::getEncodedGPR(Dest->getRegNum()); RegX8632::GPRRegister DestReg = RegX8632::getEncodedGPR(Dest->getRegNum());
...@@ -778,14 +663,12 @@ void emitIASGPRShiftDouble(const Cfg *Func, const Variable *Dest, ...@@ -778,14 +663,12 @@ void emitIASGPRShiftDouble(const Cfg *Func, const Variable *Dest,
assert(llvm::cast<Variable>(Src2Op)->getRegNum() == RegX8632::Reg_ecx); assert(llvm::cast<Variable>(Src2Op)->getRegNum() == RegX8632::Reg_ecx);
(Asm->*(Emitter.GPRGPR))(Ty, DestReg, SrcReg); (Asm->*(Emitter.GPRGPR))(Ty, DestReg, SrcReg);
} }
emitIASBytes(Func, Asm, StartPosition);
} }
void emitIASXmmShift(const Cfg *Func, Type Ty, const Variable *Var, void emitIASXmmShift(const Cfg *Func, Type Ty, const Variable *Var,
const Operand *Src, const Operand *Src,
const x86::AssemblerX86::XmmEmitterShiftOp &Emitter) { const x86::AssemblerX86::XmmEmitterShiftOp &Emitter) {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
assert(Var->hasReg()); assert(Var->hasReg());
RegX8632::XmmRegister VarReg = RegX8632::getEncodedXmm(Var->getRegNum()); RegX8632::XmmRegister VarReg = RegX8632::getEncodedXmm(Var->getRegNum());
if (const auto SrcVar = llvm::dyn_cast<Variable>(Src)) { if (const auto SrcVar = llvm::dyn_cast<Variable>(Src)) {
...@@ -806,14 +689,12 @@ void emitIASXmmShift(const Cfg *Func, Type Ty, const Variable *Var, ...@@ -806,14 +689,12 @@ void emitIASXmmShift(const Cfg *Func, Type Ty, const Variable *Var,
} else { } else {
llvm_unreachable("Unexpected operand type"); llvm_unreachable("Unexpected operand type");
} }
emitIASBytes(Func, Asm, StartPosition);
} }
void emitIASRegOpTyXMM(const Cfg *Func, Type Ty, const Variable *Var, void emitIASRegOpTyXMM(const Cfg *Func, Type Ty, const Variable *Var,
const Operand *Src, const Operand *Src,
const x86::AssemblerX86::XmmEmitterRegOp &Emitter) { const x86::AssemblerX86::XmmEmitterRegOp &Emitter) {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
assert(Var->hasReg()); assert(Var->hasReg());
RegX8632::XmmRegister VarReg = RegX8632::getEncodedXmm(Var->getRegNum()); RegX8632::XmmRegister VarReg = RegX8632::getEncodedXmm(Var->getRegNum());
if (const auto SrcVar = llvm::dyn_cast<Variable>(Src)) { if (const auto SrcVar = llvm::dyn_cast<Variable>(Src)) {
...@@ -835,7 +716,6 @@ void emitIASRegOpTyXMM(const Cfg *Func, Type Ty, const Variable *Var, ...@@ -835,7 +716,6 @@ void emitIASRegOpTyXMM(const Cfg *Func, Type Ty, const Variable *Var,
} else { } else {
llvm_unreachable("Unexpected operand type"); llvm_unreachable("Unexpected operand type");
} }
emitIASBytes(Func, Asm, StartPosition);
} }
template <typename DReg_t, typename SReg_t, DReg_t (*destEnc)(int32_t), template <typename DReg_t, typename SReg_t, DReg_t (*destEnc)(int32_t),
...@@ -844,7 +724,6 @@ void emitIASCastRegOp( ...@@ -844,7 +724,6 @@ void emitIASCastRegOp(
const Cfg *Func, Type DispatchTy, const Variable *Dest, const Operand *Src, const Cfg *Func, Type DispatchTy, const Variable *Dest, const Operand *Src,
const x86::AssemblerX86::CastEmitterRegOp<DReg_t, SReg_t> Emitter) { const x86::AssemblerX86::CastEmitterRegOp<DReg_t, SReg_t> Emitter) {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
assert(Dest->hasReg()); assert(Dest->hasReg());
DReg_t DestReg = destEnc(Dest->getRegNum()); DReg_t DestReg = destEnc(Dest->getRegNum());
if (const auto SrcVar = llvm::dyn_cast<Variable>(Src)) { if (const auto SrcVar = llvm::dyn_cast<Variable>(Src)) {
...@@ -862,7 +741,6 @@ void emitIASCastRegOp( ...@@ -862,7 +741,6 @@ void emitIASCastRegOp(
} else { } else {
llvm_unreachable("Unexpected operand type"); llvm_unreachable("Unexpected operand type");
} }
emitIASBytes(Func, Asm, StartPosition);
} }
template <typename DReg_t, typename SReg_t, DReg_t (*destEnc)(int32_t), template <typename DReg_t, typename SReg_t, DReg_t (*destEnc)(int32_t),
...@@ -872,7 +750,6 @@ void emitIASThreeOpImmOps( ...@@ -872,7 +750,6 @@ void emitIASThreeOpImmOps(
const Operand *Src1, const Operand *Src1,
const x86::AssemblerX86::ThreeOpImmEmitter<DReg_t, SReg_t> Emitter) { const x86::AssemblerX86::ThreeOpImmEmitter<DReg_t, SReg_t> Emitter) {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
// This only handles Dest being a register, and Src1 being an immediate. // This only handles Dest being a register, and Src1 being an immediate.
assert(Dest->hasReg()); assert(Dest->hasReg());
DReg_t DestReg = destEnc(Dest->getRegNum()); DReg_t DestReg = destEnc(Dest->getRegNum());
...@@ -893,14 +770,12 @@ void emitIASThreeOpImmOps( ...@@ -893,14 +770,12 @@ void emitIASThreeOpImmOps(
} else { } else {
llvm_unreachable("Unexpected operand type"); llvm_unreachable("Unexpected operand type");
} }
emitIASBytes(Func, Asm, StartPosition);
} }
void emitIASMovlikeXMM(const Cfg *Func, const Variable *Dest, void emitIASMovlikeXMM(const Cfg *Func, const Variable *Dest,
const Operand *Src, const Operand *Src,
const x86::AssemblerX86::XmmEmitterMovOps Emitter) { const x86::AssemblerX86::XmmEmitterMovOps Emitter) {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
if (Dest->hasReg()) { if (Dest->hasReg()) {
RegX8632::XmmRegister DestReg = RegX8632::getEncodedXmm(Dest->getRegNum()); RegX8632::XmmRegister DestReg = RegX8632::getEncodedXmm(Dest->getRegNum());
if (const auto SrcVar = llvm::dyn_cast<Variable>(Src)) { if (const auto SrcVar = llvm::dyn_cast<Variable>(Src)) {
...@@ -927,7 +802,6 @@ void emitIASMovlikeXMM(const Cfg *Func, const Variable *Dest, ...@@ -927,7 +802,6 @@ void emitIASMovlikeXMM(const Cfg *Func, const Variable *Dest,
(Asm->*(Emitter.AddrXmm))(StackAddr, (Asm->*(Emitter.AddrXmm))(StackAddr,
RegX8632::getEncodedXmm(SrcVar->getRegNum())); RegX8632::getEncodedXmm(SrcVar->getRegNum()));
} }
emitIASBytes(Func, Asm, StartPosition);
} }
bool checkForRedundantAssign(const Variable *Dest, const Operand *Source) { bool checkForRedundantAssign(const Variable *Dest, const Operand *Source) {
...@@ -1432,7 +1306,6 @@ template <> void InstX8632Cbwdq::emit(const Cfg *Func) const { ...@@ -1432,7 +1306,6 @@ template <> void InstX8632Cbwdq::emit(const Cfg *Func) const {
template <> void InstX8632Cbwdq::emitIAS(const Cfg *Func) const { template <> void InstX8632Cbwdq::emitIAS(const Cfg *Func) const {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
assert(getSrcSize() == 1); assert(getSrcSize() == 1);
Operand *Src0 = getSrc(0); Operand *Src0 = getSrc(0);
assert(llvm::isa<Variable>(Src0)); assert(llvm::isa<Variable>(Src0));
...@@ -1454,7 +1327,6 @@ template <> void InstX8632Cbwdq::emitIAS(const Cfg *Func) const { ...@@ -1454,7 +1327,6 @@ template <> void InstX8632Cbwdq::emitIAS(const Cfg *Func) const {
Asm->cdq(); Asm->cdq();
break; break;
} }
emitIASBytes(Func, Asm, StartPosition);
} }
void InstX8632Mul::emit(const Cfg *Func) const { void InstX8632Mul::emit(const Cfg *Func) const {
...@@ -1582,10 +1454,8 @@ void InstX8632Cmov::emitIAS(const Cfg *Func) const { ...@@ -1582,10 +1454,8 @@ void InstX8632Cmov::emitIAS(const Cfg *Func) const {
assert(SrcVar->hasReg()); assert(SrcVar->hasReg());
assert(SrcVar->getType() == IceType_i32); assert(SrcVar->getType() == IceType_i32);
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
Asm->cmov(Condition, RegX8632::getEncodedGPR(getDest()->getRegNum()), Asm->cmov(Condition, RegX8632::getEncodedGPR(getDest()->getRegNum()),
RegX8632::getEncodedGPR(SrcVar->getRegNum())); RegX8632::getEncodedGPR(SrcVar->getRegNum()));
emitIASBytes(Func, Asm, StartPosition);
} }
void InstX8632Cmov::dump(const Cfg *Func) const { void InstX8632Cmov::dump(const Cfg *Func) const {
...@@ -1611,7 +1481,6 @@ void InstX8632Cmpps::emit(const Cfg *Func) const { ...@@ -1611,7 +1481,6 @@ void InstX8632Cmpps::emit(const Cfg *Func) const {
void InstX8632Cmpps::emitIAS(const Cfg *Func) const { void InstX8632Cmpps::emitIAS(const Cfg *Func) const {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
assert(getSrcSize() == 2); assert(getSrcSize() == 2);
assert(Condition < CondX86::Cmpps_Invalid); assert(Condition < CondX86::Cmpps_Invalid);
// Assuming there isn't any load folding for cmpps, and vector constants // Assuming there isn't any load folding for cmpps, and vector constants
...@@ -1627,7 +1496,6 @@ void InstX8632Cmpps::emitIAS(const Cfg *Func) const { ...@@ -1627,7 +1496,6 @@ void InstX8632Cmpps::emitIAS(const Cfg *Func) const {
Asm->cmpps(RegX8632::getEncodedXmm(getDest()->getRegNum()), SrcStackAddr, Asm->cmpps(RegX8632::getEncodedXmm(getDest()->getRegNum()), SrcStackAddr,
Condition); Condition);
} }
emitIASBytes(Func, Asm, StartPosition);
} }
void InstX8632Cmpps::dump(const Cfg *Func) const { void InstX8632Cmpps::dump(const Cfg *Func) const {
...@@ -1654,7 +1522,6 @@ void InstX8632Cmpxchg::emit(const Cfg *Func) const { ...@@ -1654,7 +1522,6 @@ void InstX8632Cmpxchg::emit(const Cfg *Func) const {
void InstX8632Cmpxchg::emitIAS(const Cfg *Func) const { void InstX8632Cmpxchg::emitIAS(const Cfg *Func) const {
assert(getSrcSize() == 3); assert(getSrcSize() == 3);
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
Type Ty = getSrc(0)->getType(); Type Ty = getSrc(0)->getType();
const auto Mem = llvm::cast<OperandX8632Mem>(getSrc(0)); const auto Mem = llvm::cast<OperandX8632Mem>(getSrc(0));
assert(Mem->getSegmentRegister() == OperandX8632Mem::DefaultSegment); assert(Mem->getSegmentRegister() == OperandX8632Mem::DefaultSegment);
...@@ -1668,7 +1535,6 @@ void InstX8632Cmpxchg::emitIAS(const Cfg *Func) const { ...@@ -1668,7 +1535,6 @@ void InstX8632Cmpxchg::emitIAS(const Cfg *Func) const {
} else { } else {
Asm->cmpxchg(Ty, Addr, Reg); Asm->cmpxchg(Ty, Addr, Reg);
} }
emitIASBytes(Func, Asm, StartPosition);
} }
void InstX8632Cmpxchg::dump(const Cfg *Func) const { void InstX8632Cmpxchg::dump(const Cfg *Func) const {
...@@ -1693,7 +1559,6 @@ void InstX8632Cmpxchg8b::emit(const Cfg *Func) const { ...@@ -1693,7 +1559,6 @@ void InstX8632Cmpxchg8b::emit(const Cfg *Func) const {
void InstX8632Cmpxchg8b::emitIAS(const Cfg *Func) const { void InstX8632Cmpxchg8b::emitIAS(const Cfg *Func) const {
assert(getSrcSize() == 5); assert(getSrcSize() == 5);
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
const auto Mem = llvm::cast<OperandX8632Mem>(getSrc(0)); const auto Mem = llvm::cast<OperandX8632Mem>(getSrc(0));
assert(Mem->getSegmentRegister() == OperandX8632Mem::DefaultSegment); assert(Mem->getSegmentRegister() == OperandX8632Mem::DefaultSegment);
const x86::Address Addr = Mem->toAsmAddress(Asm); const x86::Address Addr = Mem->toAsmAddress(Asm);
...@@ -1701,7 +1566,6 @@ void InstX8632Cmpxchg8b::emitIAS(const Cfg *Func) const { ...@@ -1701,7 +1566,6 @@ void InstX8632Cmpxchg8b::emitIAS(const Cfg *Func) const {
Asm->lock(); Asm->lock();
} }
Asm->cmpxchg8b(Addr); Asm->cmpxchg8b(Addr);
emitIASBytes(Func, Asm, StartPosition);
} }
void InstX8632Cmpxchg8b::dump(const Cfg *Func) const { void InstX8632Cmpxchg8b::dump(const Cfg *Func) const {
...@@ -1868,9 +1732,7 @@ void InstX8632UD2::emit(const Cfg *Func) const { ...@@ -1868,9 +1732,7 @@ void InstX8632UD2::emit(const Cfg *Func) const {
void InstX8632UD2::emitIAS(const Cfg *Func) const { void InstX8632UD2::emitIAS(const Cfg *Func) const {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
Asm->ud2(); Asm->ud2();
emitIASBytes(Func, Asm, StartPosition);
} }
void InstX8632UD2::dump(const Cfg *Func) const { void InstX8632UD2::dump(const Cfg *Func) const {
...@@ -1922,9 +1784,7 @@ void InstX8632Mfence::emit(const Cfg *Func) const { ...@@ -1922,9 +1784,7 @@ void InstX8632Mfence::emit(const Cfg *Func) const {
void InstX8632Mfence::emitIAS(const Cfg *Func) const { void InstX8632Mfence::emitIAS(const Cfg *Func) const {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
Asm->mfence(); Asm->mfence();
emitIASBytes(Func, Asm, StartPosition);
} }
void InstX8632Mfence::dump(const Cfg *Func) const { void InstX8632Mfence::dump(const Cfg *Func) const {
...@@ -1954,7 +1814,6 @@ void InstX8632Store::emitIAS(const Cfg *Func) const { ...@@ -1954,7 +1814,6 @@ void InstX8632Store::emitIAS(const Cfg *Func) const {
assert(SrcVar->hasReg()); assert(SrcVar->hasReg());
RegX8632::XmmRegister SrcReg = RegX8632::getEncodedXmm(SrcVar->getRegNum()); RegX8632::XmmRegister SrcReg = RegX8632::getEncodedXmm(SrcVar->getRegNum());
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
if (const auto DestVar = llvm::dyn_cast<Variable>(Dest)) { if (const auto DestVar = llvm::dyn_cast<Variable>(Dest)) {
assert(!DestVar->hasReg()); assert(!DestVar->hasReg());
x86::Address StackAddr(static_cast<TargetX8632 *>(Func->getTarget()) x86::Address StackAddr(static_cast<TargetX8632 *>(Func->getTarget())
...@@ -1965,7 +1824,6 @@ void InstX8632Store::emitIAS(const Cfg *Func) const { ...@@ -1965,7 +1824,6 @@ void InstX8632Store::emitIAS(const Cfg *Func) const {
assert(DestMem->getSegmentRegister() == OperandX8632Mem::DefaultSegment); assert(DestMem->getSegmentRegister() == OperandX8632Mem::DefaultSegment);
Asm->movss(DestTy, DestMem->toAsmAddress(Asm), SrcReg); Asm->movss(DestTy, DestMem->toAsmAddress(Asm), SrcReg);
} }
emitIASBytes(Func, Asm, StartPosition);
return; return;
} else { } else {
assert(isScalarIntegerType(DestTy)); assert(isScalarIntegerType(DestTy));
...@@ -1994,7 +1852,6 @@ void InstX8632StoreP::emit(const Cfg *Func) const { ...@@ -1994,7 +1852,6 @@ void InstX8632StoreP::emit(const Cfg *Func) const {
void InstX8632StoreP::emitIAS(const Cfg *Func) const { void InstX8632StoreP::emitIAS(const Cfg *Func) const {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
assert(getSrcSize() == 2); assert(getSrcSize() == 2);
const auto SrcVar = llvm::cast<Variable>(getSrc(0)); const auto SrcVar = llvm::cast<Variable>(getSrc(0));
const auto DestMem = llvm::cast<OperandX8632Mem>(getSrc(1)); const auto DestMem = llvm::cast<OperandX8632Mem>(getSrc(1));
...@@ -2002,7 +1859,6 @@ void InstX8632StoreP::emitIAS(const Cfg *Func) const { ...@@ -2002,7 +1859,6 @@ void InstX8632StoreP::emitIAS(const Cfg *Func) const {
assert(SrcVar->hasReg()); assert(SrcVar->hasReg());
Asm->movups(DestMem->toAsmAddress(Asm), Asm->movups(DestMem->toAsmAddress(Asm),
RegX8632::getEncodedXmm(SrcVar->getRegNum())); RegX8632::getEncodedXmm(SrcVar->getRegNum()));
emitIASBytes(Func, Asm, StartPosition);
} }
void InstX8632StoreP::dump(const Cfg *Func) const { void InstX8632StoreP::dump(const Cfg *Func) const {
...@@ -2026,7 +1882,6 @@ void InstX8632StoreQ::emit(const Cfg *Func) const { ...@@ -2026,7 +1882,6 @@ void InstX8632StoreQ::emit(const Cfg *Func) const {
void InstX8632StoreQ::emitIAS(const Cfg *Func) const { void InstX8632StoreQ::emitIAS(const Cfg *Func) const {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
assert(getSrcSize() == 2); assert(getSrcSize() == 2);
const auto SrcVar = llvm::cast<Variable>(getSrc(0)); const auto SrcVar = llvm::cast<Variable>(getSrc(0));
const auto DestMem = llvm::cast<OperandX8632Mem>(getSrc(1)); const auto DestMem = llvm::cast<OperandX8632Mem>(getSrc(1));
...@@ -2034,7 +1889,6 @@ void InstX8632StoreQ::emitIAS(const Cfg *Func) const { ...@@ -2034,7 +1889,6 @@ void InstX8632StoreQ::emitIAS(const Cfg *Func) const {
assert(SrcVar->hasReg()); assert(SrcVar->hasReg());
Asm->movq(DestMem->toAsmAddress(Asm), Asm->movq(DestMem->toAsmAddress(Asm),
RegX8632::getEncodedXmm(SrcVar->getRegNum())); RegX8632::getEncodedXmm(SrcVar->getRegNum()));
emitIASBytes(Func, Asm, StartPosition);
} }
void InstX8632StoreQ::dump(const Cfg *Func) const { void InstX8632StoreQ::dump(const Cfg *Func) const {
...@@ -2145,10 +1999,8 @@ template <> void InstX8632Mov::emitIAS(const Cfg *Func) const { ...@@ -2145,10 +1999,8 @@ template <> void InstX8632Mov::emitIAS(const Cfg *Func) const {
const auto SrcVar = llvm::cast<Variable>(Src); const auto SrcVar = llvm::cast<Variable>(Src);
assert(SrcVar->hasReg()); assert(SrcVar->hasReg());
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
Asm->movss(SrcTy, StackAddr, Asm->movss(SrcTy, StackAddr,
RegX8632::getEncodedXmm(SrcVar->getRegNum())); RegX8632::getEncodedXmm(SrcVar->getRegNum()));
emitIASBytes(Func, Asm, StartPosition);
return; return;
} else { } else {
// Src can be a register or immediate. // Src can be a register or immediate.
...@@ -2162,7 +2014,6 @@ template <> void InstX8632Mov::emitIAS(const Cfg *Func) const { ...@@ -2162,7 +2014,6 @@ template <> void InstX8632Mov::emitIAS(const Cfg *Func) const {
template <> void InstX8632Movd::emitIAS(const Cfg *Func) const { template <> void InstX8632Movd::emitIAS(const Cfg *Func) const {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
assert(getSrcSize() == 1); assert(getSrcSize() == 1);
const Variable *Dest = getDest(); const Variable *Dest = getDest();
const auto SrcVar = llvm::cast<Variable>(getSrc(0)); const auto SrcVar = llvm::cast<Variable>(getSrc(0));
...@@ -2192,7 +2043,6 @@ template <> void InstX8632Movd::emitIAS(const Cfg *Func) const { ...@@ -2192,7 +2043,6 @@ template <> void InstX8632Movd::emitIAS(const Cfg *Func) const {
Asm->movd(StackAddr, SrcReg); Asm->movd(StackAddr, SrcReg);
} }
} }
emitIASBytes(Func, Asm, StartPosition);
} }
template <> void InstX8632Movp::emit(const Cfg *Func) const { template <> void InstX8632Movp::emit(const Cfg *Func) const {
...@@ -2252,10 +2102,8 @@ template <> void InstX8632MovssRegs::emitIAS(const Cfg *Func) const { ...@@ -2252,10 +2102,8 @@ template <> void InstX8632MovssRegs::emitIAS(const Cfg *Func) const {
const auto SrcVar = llvm::cast<Variable>(getSrc(1)); const auto SrcVar = llvm::cast<Variable>(getSrc(1));
assert(Dest->hasReg() && SrcVar->hasReg()); assert(Dest->hasReg() && SrcVar->hasReg());
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
Asm->movss(IceType_f32, RegX8632::getEncodedXmm(Dest->getRegNum()), Asm->movss(IceType_f32, RegX8632::getEncodedXmm(Dest->getRegNum()),
RegX8632::getEncodedXmm(SrcVar->getRegNum())); RegX8632::getEncodedXmm(SrcVar->getRegNum()));
emitIASBytes(Func, Asm, StartPosition);
} }
template <> void InstX8632Movsx::emitIAS(const Cfg *Func) const { template <> void InstX8632Movsx::emitIAS(const Cfg *Func) const {
...@@ -2289,10 +2137,8 @@ void InstX8632Nop::emit(const Cfg *Func) const { ...@@ -2289,10 +2137,8 @@ void InstX8632Nop::emit(const Cfg *Func) const {
void InstX8632Nop::emitIAS(const Cfg *Func) const { void InstX8632Nop::emitIAS(const Cfg *Func) const {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
// TODO: Emit the right code for the variant. // TODO: Emit the right code for the variant.
Asm->nop(); Asm->nop();
emitIASBytes(Func, Asm, StartPosition);
} }
void InstX8632Nop::dump(const Cfg *Func) const { void InstX8632Nop::dump(const Cfg *Func) const {
...@@ -2325,7 +2171,6 @@ void InstX8632Fld::emit(const Cfg *Func) const { ...@@ -2325,7 +2171,6 @@ void InstX8632Fld::emit(const Cfg *Func) const {
void InstX8632Fld::emitIAS(const Cfg *Func) const { void InstX8632Fld::emitIAS(const Cfg *Func) const {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
assert(getSrcSize() == 1); assert(getSrcSize() == 1);
const Operand *Src = getSrc(0); const Operand *Src = getSrc(0);
Type Ty = Src->getType(); Type Ty = Src->getType();
...@@ -2352,7 +2197,6 @@ void InstX8632Fld::emitIAS(const Cfg *Func) const { ...@@ -2352,7 +2197,6 @@ void InstX8632Fld::emitIAS(const Cfg *Func) const {
} else { } else {
llvm_unreachable("Unexpected operand type"); llvm_unreachable("Unexpected operand type");
} }
emitIASBytes(Func, Asm, StartPosition);
} }
void InstX8632Fld::dump(const Cfg *Func) const { void InstX8632Fld::dump(const Cfg *Func) const {
...@@ -2395,7 +2239,6 @@ void InstX8632Fstp::emit(const Cfg *Func) const { ...@@ -2395,7 +2239,6 @@ void InstX8632Fstp::emit(const Cfg *Func) const {
void InstX8632Fstp::emitIAS(const Cfg *Func) const { void InstX8632Fstp::emitIAS(const Cfg *Func) const {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
assert(getSrcSize() == 0); assert(getSrcSize() == 0);
const Variable *Dest = getDest(); const Variable *Dest = getDest();
// TODO(jvoung,stichnot): Utilize this by setting Dest to nullptr to // TODO(jvoung,stichnot): Utilize this by setting Dest to nullptr to
...@@ -2404,7 +2247,6 @@ void InstX8632Fstp::emitIAS(const Cfg *Func) const { ...@@ -2404,7 +2247,6 @@ void InstX8632Fstp::emitIAS(const Cfg *Func) const {
// of popping the stack. // of popping the stack.
if (!Dest) { if (!Dest) {
Asm->fstp(RegX8632::getEncodedSTReg(0)); Asm->fstp(RegX8632::getEncodedSTReg(0));
emitIASBytes(Func, Asm, StartPosition);
return; return;
} }
Type Ty = Dest->getType(); Type Ty = Dest->getType();
...@@ -2424,7 +2266,6 @@ void InstX8632Fstp::emitIAS(const Cfg *Func) const { ...@@ -2424,7 +2266,6 @@ void InstX8632Fstp::emitIAS(const Cfg *Func) const {
Asm->movss(Ty, RegX8632::getEncodedXmm(Dest->getRegNum()), StackSlot); Asm->movss(Ty, RegX8632::getEncodedXmm(Dest->getRegNum()), StackSlot);
Asm->add(IceType_i32, RegX8632::Encoded_Reg_esp, Width); Asm->add(IceType_i32, RegX8632::Encoded_Reg_esp, Width);
} }
emitIASBytes(Func, Asm, StartPosition);
} }
void InstX8632Fstp::dump(const Cfg *Func) const { void InstX8632Fstp::dump(const Cfg *Func) const {
...@@ -2575,14 +2416,12 @@ void InstX8632Pop::emit(const Cfg *Func) const { ...@@ -2575,14 +2416,12 @@ void InstX8632Pop::emit(const Cfg *Func) const {
void InstX8632Pop::emitIAS(const Cfg *Func) const { void InstX8632Pop::emitIAS(const Cfg *Func) const {
assert(getSrcSize() == 0); assert(getSrcSize() == 0);
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
if (getDest()->hasReg()) { if (getDest()->hasReg()) {
Asm->popl(RegX8632::getEncodedGPR(getDest()->getRegNum())); Asm->popl(RegX8632::getEncodedGPR(getDest()->getRegNum()));
} else { } else {
Asm->popl(static_cast<TargetX8632 *>(Func->getTarget()) Asm->popl(static_cast<TargetX8632 *>(Func->getTarget())
->stackVarToAsmOperand(getDest())); ->stackVarToAsmOperand(getDest()));
} }
emitIASBytes(Func, Asm, StartPosition);
} }
void InstX8632Pop::dump(const Cfg *Func) const { void InstX8632Pop::dump(const Cfg *Func) const {
...@@ -2599,9 +2438,7 @@ void InstX8632AdjustStack::emit(const Cfg *Func) const { ...@@ -2599,9 +2438,7 @@ void InstX8632AdjustStack::emit(const Cfg *Func) const {
void InstX8632AdjustStack::emitIAS(const Cfg *Func) const { void InstX8632AdjustStack::emitIAS(const Cfg *Func) const {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
Asm->sub(IceType_i32, RegX8632::Encoded_Reg_esp, x86::Immediate(Amount)); Asm->sub(IceType_i32, RegX8632::Encoded_Reg_esp, x86::Immediate(Amount));
emitIASBytes(Func, Asm, StartPosition);
Func->getTarget()->updateStackAdjustment(Amount); Func->getTarget()->updateStackAdjustment(Amount);
} }
...@@ -2626,9 +2463,7 @@ void InstX8632Push::emitIAS(const Cfg *Func) const { ...@@ -2626,9 +2463,7 @@ void InstX8632Push::emitIAS(const Cfg *Func) const {
const auto Var = llvm::cast<Variable>(getSrc(0)); const auto Var = llvm::cast<Variable>(getSrc(0));
assert(Var->hasReg()); assert(Var->hasReg());
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
Asm->pushl(RegX8632::getEncodedGPR(Var->getRegNum())); Asm->pushl(RegX8632::getEncodedGPR(Var->getRegNum()));
emitIASBytes(Func, Asm, StartPosition);
} }
void InstX8632Push::dump(const Cfg *Func) const { void InstX8632Push::dump(const Cfg *Func) const {
...@@ -2666,9 +2501,7 @@ void InstX8632Ret::emit(const Cfg *Func) const { ...@@ -2666,9 +2501,7 @@ void InstX8632Ret::emit(const Cfg *Func) const {
void InstX8632Ret::emitIAS(const Cfg *Func) const { void InstX8632Ret::emitIAS(const Cfg *Func) const {
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
Asm->ret(); Asm->ret();
emitIASBytes(Func, Asm, StartPosition);
} }
void InstX8632Ret::dump(const Cfg *Func) const { void InstX8632Ret::dump(const Cfg *Func) const {
...@@ -2692,7 +2525,6 @@ void InstX8632Xadd::emit(const Cfg *Func) const { ...@@ -2692,7 +2525,6 @@ void InstX8632Xadd::emit(const Cfg *Func) const {
void InstX8632Xadd::emitIAS(const Cfg *Func) const { void InstX8632Xadd::emitIAS(const Cfg *Func) const {
assert(getSrcSize() == 2); assert(getSrcSize() == 2);
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
Type Ty = getSrc(0)->getType(); Type Ty = getSrc(0)->getType();
const auto Mem = llvm::cast<OperandX8632Mem>(getSrc(0)); const auto Mem = llvm::cast<OperandX8632Mem>(getSrc(0));
assert(Mem->getSegmentRegister() == OperandX8632Mem::DefaultSegment); assert(Mem->getSegmentRegister() == OperandX8632Mem::DefaultSegment);
...@@ -2705,7 +2537,6 @@ void InstX8632Xadd::emitIAS(const Cfg *Func) const { ...@@ -2705,7 +2537,6 @@ void InstX8632Xadd::emitIAS(const Cfg *Func) const {
Asm->lock(); Asm->lock();
} }
Asm->xadd(Ty, Addr, Reg); Asm->xadd(Ty, Addr, Reg);
emitIASBytes(Func, Asm, StartPosition);
} }
void InstX8632Xadd::dump(const Cfg *Func) const { void InstX8632Xadd::dump(const Cfg *Func) const {
...@@ -2729,7 +2560,6 @@ void InstX8632Xchg::emit(const Cfg *Func) const { ...@@ -2729,7 +2560,6 @@ void InstX8632Xchg::emit(const Cfg *Func) const {
void InstX8632Xchg::emitIAS(const Cfg *Func) const { void InstX8632Xchg::emitIAS(const Cfg *Func) const {
assert(getSrcSize() == 2); assert(getSrcSize() == 2);
x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>(); x86::AssemblerX86 *Asm = Func->getAssembler<x86::AssemblerX86>();
intptr_t StartPosition = Asm->GetPosition();
Type Ty = getSrc(0)->getType(); Type Ty = getSrc(0)->getType();
const auto Mem = llvm::cast<OperandX8632Mem>(getSrc(0)); const auto Mem = llvm::cast<OperandX8632Mem>(getSrc(0));
assert(Mem->getSegmentRegister() == OperandX8632Mem::DefaultSegment); assert(Mem->getSegmentRegister() == OperandX8632Mem::DefaultSegment);
...@@ -2739,7 +2569,6 @@ void InstX8632Xchg::emitIAS(const Cfg *Func) const { ...@@ -2739,7 +2569,6 @@ void InstX8632Xchg::emitIAS(const Cfg *Func) const {
const RegX8632::GPRRegister Reg = const RegX8632::GPRRegister Reg =
RegX8632::getEncodedGPR(VarReg->getRegNum()); RegX8632::getEncodedGPR(VarReg->getRegNum());
Asm->xchg(Ty, Addr, Reg); Asm->xchg(Ty, Addr, Reg);
emitIASBytes(Func, Asm, StartPosition);
} }
void InstX8632Xchg::dump(const Cfg *Func) const { void InstX8632Xchg::dump(const Cfg *Func) const {
......
...@@ -83,7 +83,11 @@ void Translator::translateFcn(Cfg *Fcn) { ...@@ -83,7 +83,11 @@ void Translator::translateFcn(Cfg *Fcn) {
ErrorStatus = true; ErrorStatus = true;
} }
Func->emit(); if (Ctx->getFlags().UseIntegratedAssembler) {
Func->emitIAS();
} else {
Func->emit();
}
Ctx->dumpStats(Func->getFunctionName()); Ctx->dumpStats(Func->getFunctionName());
} }
......
...@@ -19,7 +19,9 @@ ...@@ -19,7 +19,9 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "assembler.h" #include "assembler.h"
#include "IceGlobalContext.h"
#include "IceMemoryRegion.h" #include "IceMemoryRegion.h"
#include "IceOperand.h"
namespace Ice { namespace Ice {
...@@ -74,18 +76,6 @@ AssemblerBuffer::AssemblerBuffer(Assembler &assembler) : assembler_(assembler) { ...@@ -74,18 +76,6 @@ AssemblerBuffer::AssemblerBuffer(Assembler &assembler) : assembler_(assembler) {
AssemblerBuffer::~AssemblerBuffer() {} AssemblerBuffer::~AssemblerBuffer() {}
// Returns the latest fixup at or after the given position, or nullptr if
// there is none. Assumes fixups were added in increasing order.
AssemblerFixup *AssemblerBuffer::GetLatestFixup(intptr_t position) const {
AssemblerFixup *latest_fixup = nullptr;
for (auto I = fixups_.rbegin(), E = fixups_.rend(); I != E; ++I) {
if ((*I)->position() < position)
return latest_fixup;
latest_fixup = *I;
}
return latest_fixup;
}
void AssemblerBuffer::ProcessFixups(const MemoryRegion &region) { void AssemblerBuffer::ProcessFixups(const MemoryRegion &region) {
for (SizeT I = 0; I < fixups_.size(); ++I) { for (SizeT I = 0; I < fixups_.size(); ++I) {
AssemblerFixup *fixup = fixups_[I]; AssemblerFixup *fixup = fixups_[I];
...@@ -133,4 +123,43 @@ void AssemblerBuffer::ExtendCapacity() { ...@@ -133,4 +123,43 @@ void AssemblerBuffer::ExtendCapacity() {
assert(Size() == old_size); assert(Size() == old_size);
} }
void Assembler::emitIASBytes(GlobalContext *Ctx) const {
Ostream &Str = Ctx->getStrEmit();
intptr_t EndPosition = buffer_.Size();
intptr_t CurPosition = 0;
const intptr_t FixupSize = 4;
for (AssemblerBuffer::FixupList::const_iterator
FixupI = buffer_.fixups_begin(),
FixupE = buffer_.fixups_end(); FixupI != FixupE; ++FixupI) {
AssemblerFixup *NextFixup = *FixupI;
intptr_t NextFixupLoc = NextFixup->position();
for (intptr_t i = CurPosition; i < NextFixupLoc; ++i) {
Str << "\t.byte 0x";
Str.write_hex(buffer_.Load<uint8_t>(i));
Str << "\n";
}
Str << "\t.long ";
const ConstantRelocatable *Reloc = NextFixup->value();
if (Reloc->getSuppressMangling())
Str << Reloc->getName();
else
Str << Ctx->mangleName(Reloc->getName());
if (Reloc->getOffset()) {
Str << " + " << Reloc->getOffset();
}
bool IsPCRel = NextFixup->kind() == FK_PcRel_4;
if (IsPCRel)
Str << " - (. + " << FixupSize << ")";
Str << "\n";
CurPosition = NextFixupLoc + FixupSize;
assert(CurPosition <= EndPosition);
}
// Handle any bytes that are not prefixed by a fixup.
for (intptr_t i = CurPosition; i < EndPosition; ++i) {
Str << "\t.byte 0x";
Str.write_hex(buffer_.Load<uint8_t>(i));
Str << "\n";
}
}
} // end of namespace Ice } // end of namespace Ice
...@@ -162,8 +162,10 @@ public: ...@@ -162,8 +162,10 @@ public:
// Returns the position in the instruction stream. // Returns the position in the instruction stream.
intptr_t GetPosition() const { return cursor_ - contents_; } intptr_t GetPosition() const { return cursor_ - contents_; }
// For bringup only. // List of pool-allocated fixups.
AssemblerFixup *GetLatestFixup(intptr_t position) const; typedef std::vector<AssemblerFixup *> FixupList;
FixupList::const_iterator fixups_begin() const { return fixups_.begin(); }
FixupList::const_iterator fixups_end() const { return fixups_.end(); }
private: private:
// The limit is set to kMinimumGap bytes before the end of the data area. // The limit is set to kMinimumGap bytes before the end of the data area.
...@@ -175,7 +177,7 @@ private: ...@@ -175,7 +177,7 @@ private:
uintptr_t cursor_; uintptr_t cursor_;
uintptr_t limit_; uintptr_t limit_;
Assembler &assembler_; Assembler &assembler_;
std::vector<AssemblerFixup *> fixups_; FixupList fixups_;
#ifndef NDEBUG #ifndef NDEBUG
bool fixups_processed_; bool fixups_processed_;
#endif // !NDEBUG #endif // !NDEBUG
...@@ -206,7 +208,7 @@ class Assembler { ...@@ -206,7 +208,7 @@ class Assembler {
Assembler &operator=(const Assembler &) = delete; Assembler &operator=(const Assembler &) = delete;
public: public:
Assembler() {} Assembler() : buffer_(*this) {}
virtual ~Assembler() {} virtual ~Assembler() {}
// Allocate a chunk of bytes using the per-Assembler allocator. // Allocate a chunk of bytes using the per-Assembler allocator.
...@@ -226,8 +228,13 @@ public: ...@@ -226,8 +228,13 @@ public:
virtual void BindCfgNodeLabel(SizeT NodeNumber) = 0; virtual void BindCfgNodeLabel(SizeT NodeNumber) = 0;
void emitIASBytes(GlobalContext *Ctx) const;
private: private:
llvm::BumpPtrAllocator Allocator; llvm::BumpPtrAllocator Allocator;
protected:
AssemblerBuffer buffer_;
}; };
} // end of namespace Ice } // end of namespace Ice
......
...@@ -364,7 +364,7 @@ class AssemblerX86 : public Assembler { ...@@ -364,7 +364,7 @@ class AssemblerX86 : public Assembler {
AssemblerX86 &operator=(const AssemblerX86 &) = delete; AssemblerX86 &operator=(const AssemblerX86 &) = delete;
public: public:
explicit AssemblerX86(bool use_far_branches = false) : buffer_(*this) { explicit AssemblerX86(bool use_far_branches = false) : Assembler() {
// This mode is only needed and implemented for MIPS and ARM. // This mode is only needed and implemented for MIPS and ARM.
assert(!use_far_branches); assert(!use_far_branches);
(void)use_far_branches; (void)use_far_branches;
...@@ -829,15 +829,6 @@ public: ...@@ -829,15 +829,6 @@ public:
buffer_.FinalizeInstructions(region); buffer_.FinalizeInstructions(region);
} }
// Expose the buffer, for bringup...
intptr_t GetPosition() const { return buffer_.GetPosition(); }
template <typename T> T LoadBuffer(intptr_t position) const {
return buffer_.Load<T>(position);
}
AssemblerFixup *GetLatestFixup(intptr_t position) const {
return buffer_.GetLatestFixup(position);
}
private: private:
inline void EmitUint8(uint8_t value); inline void EmitUint8(uint8_t value);
inline void EmitInt16(int16_t value); inline void EmitInt16(int16_t value);
...@@ -868,8 +859,6 @@ private: ...@@ -868,8 +859,6 @@ private:
LabelVector LocalLabels; LabelVector LocalLabels;
Label *GetOrCreateLabel(SizeT Number, LabelVector &Labels); Label *GetOrCreateLabel(SizeT Number, LabelVector &Labels);
AssemblerBuffer buffer_;
}; };
inline void AssemblerX86::EmitUint8(uint8_t value) { inline void AssemblerX86::EmitUint8(uint8_t value) {
......
...@@ -44,7 +44,7 @@ entry: ...@@ -44,7 +44,7 @@ entry:
; CHECK: mov dword ptr [esp + 16] ; CHECK: mov dword ptr [esp + 16]
; CHECK: mov dword ptr [esp + 12] ; CHECK: mov dword ptr [esp + 12]
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call ignore64BitArgNoInline ; CALLTARGETS: .long ignore64BitArgNoInline
; CHECK: sub esp ; CHECK: sub esp
; CHECK: mov dword ptr [esp + 4] ; CHECK: mov dword ptr [esp + 4]
; CHECK: mov dword ptr [esp] ; CHECK: mov dword ptr [esp]
...@@ -52,7 +52,7 @@ entry: ...@@ -52,7 +52,7 @@ entry:
; CHECK: mov dword ptr [esp + 16] ; CHECK: mov dword ptr [esp + 16]
; CHECK: mov dword ptr [esp + 12] ; CHECK: mov dword ptr [esp + 12]
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call ignore64BitArgNoInline ; CALLTARGETS: .long ignore64BitArgNoInline
; CHECK: sub esp ; CHECK: sub esp
; CHECK: mov dword ptr [esp + 4] ; CHECK: mov dword ptr [esp + 4]
; CHECK: mov dword ptr [esp] ; CHECK: mov dword ptr [esp]
...@@ -60,7 +60,7 @@ entry: ...@@ -60,7 +60,7 @@ entry:
; CHECK: mov dword ptr [esp + 16] ; CHECK: mov dword ptr [esp + 16]
; CHECK: mov dword ptr [esp + 12] ; CHECK: mov dword ptr [esp + 12]
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call ignore64BitArgNoInline ; CALLTARGETS: .long ignore64BitArgNoInline
; ;
; OPTM1-LABEL: pass64BitArg ; OPTM1-LABEL: pass64BitArg
; OPTM1: sub esp ; OPTM1: sub esp
...@@ -104,7 +104,7 @@ entry: ...@@ -104,7 +104,7 @@ entry:
; Bundle padding will push the call down. ; Bundle padding will push the call down.
; CHECK-NOT: mov ; CHECK-NOT: mov
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call ignore64BitArgNoInline ; CALLTARGETS: .long ignore64BitArgNoInline
; ;
; OPTM1-LABEL: pass64BitConstArg ; OPTM1-LABEL: pass64BitConstArg
; OPTM1: sub esp ; OPTM1: sub esp
...@@ -239,7 +239,7 @@ entry: ...@@ -239,7 +239,7 @@ entry:
; CHECK-LABEL: div64BitSigned ; CHECK-LABEL: div64BitSigned
; CALLTARGETS-LABEL: div64BitSigned ; CALLTARGETS-LABEL: div64BitSigned
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call __divdi3 ; CALLTARGETS: .long __divdi3
; OPTM1-LABEL: div64BitSigned ; OPTM1-LABEL: div64BitSigned
; OPTM1: call -4 ; OPTM1: call -4
...@@ -254,7 +254,7 @@ entry: ...@@ -254,7 +254,7 @@ entry:
; CHECK: mov dword ptr [esp + 12], 2874 ; CHECK: mov dword ptr [esp + 12], 2874
; CHECK: mov dword ptr [esp + 8], 1942892530 ; CHECK: mov dword ptr [esp + 8], 1942892530
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call __divdi3 ; CALLTARGETS: .long __divdi3
; ;
; OPTM1-LABEL: div64BitSignedConst ; OPTM1-LABEL: div64BitSignedConst
; OPTM1: mov dword ptr [esp + 12], 2874 ; OPTM1: mov dword ptr [esp + 12], 2874
...@@ -269,7 +269,7 @@ entry: ...@@ -269,7 +269,7 @@ entry:
; CHECK-LABEL: div64BitUnsigned ; CHECK-LABEL: div64BitUnsigned
; CALLTARGETS-LABEL: div64BitUnsigned ; CALLTARGETS-LABEL: div64BitUnsigned
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call __udivdi3 ; CALLTARGETS: .long __udivdi3
; ;
; OPTM1-LABEL: div64BitUnsigned ; OPTM1-LABEL: div64BitUnsigned
; OPTM1: call -4 ; OPTM1: call -4
...@@ -282,7 +282,7 @@ entry: ...@@ -282,7 +282,7 @@ entry:
; CHECK-LABEL: rem64BitSigned ; CHECK-LABEL: rem64BitSigned
; CALLTARGETS-LABEL: rem64BitSigned ; CALLTARGETS-LABEL: rem64BitSigned
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call __moddi3 ; CALLTARGETS: .long __moddi3
; ;
; OPTM1-LABEL: rem64BitSigned ; OPTM1-LABEL: rem64BitSigned
; OPTM1: call -4 ; OPTM1: call -4
...@@ -295,7 +295,7 @@ entry: ...@@ -295,7 +295,7 @@ entry:
; CHECK-LABEL: rem64BitUnsigned ; CHECK-LABEL: rem64BitUnsigned
; CALLTARGETS-LABEL: rem64BitUnsigned ; CALLTARGETS-LABEL: rem64BitUnsigned
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call __umoddi3 ; CALLTARGETS: .long __umoddi3
; ;
; OPTM1-LABEL: rem64BitUnsigned ; OPTM1-LABEL: rem64BitUnsigned
; OPTM1: call -4 ; OPTM1: call -4
......
; This is a very early test that just checks the representation of i32 ; This is a very early test that just checks the representation of i32
; arithmetic instructions. No assembly tests are done. ; arithmetic instructions. No assembly tests are done.
; RUN: %p2i -i %s --args --verbose inst | FileCheck %s ; RUN: %p2i -i %s --args --verbose inst -ias=0 | FileCheck %s
define i32 @Add(i32 %a, i32 %b) { define i32 @Add(i32 %a, i32 %b) {
; CHECK: define i32 @Add ; CHECK: define i32 @Add
......
...@@ -47,17 +47,18 @@ entry: ...@@ -47,17 +47,18 @@ entry:
ret i32 %add3 ret i32 %add3
} }
; CHECK-LABEL: passFpArgs ; CHECK-LABEL: passFpArgs
; CALLTARGETS-LABEL: passFpArgs
; CHECK: mov dword ptr [esp + 4], 123 ; CHECK: mov dword ptr [esp + 4], 123
; CHECK: call ignoreFpArgsNoInline ; CHECK: call -4
; CALLTARGETS: .long ignoreFpArgsNoInline
; CHECK: mov dword ptr [esp + 4], 123 ; CHECK: mov dword ptr [esp + 4], 123
; CHECK: call ignoreFpArgsNoInline ; CHECK: call -4
; CALLTARGETS: .long ignoreFpArgsNoInline
; CHECK: mov dword ptr [esp + 4], 123 ; CHECK: mov dword ptr [esp + 4], 123
; CHECK: call ignoreFpArgsNoInline ; CHECK: call -4
; CALLTARGETS: .long ignoreFpArgsNoInline
define i32 @ignoreFpArgsNoInline(float %x, i32 %y, double %z) { declare i32 @ignoreFpArgsNoInline(float %x, i32 %y, double %z)
entry:
ret i32 %y
}
define internal i32 @passFpConstArg(float %a, double %b) { define internal i32 @passFpConstArg(float %a, double %b) {
entry: entry:
...@@ -65,8 +66,10 @@ entry: ...@@ -65,8 +66,10 @@ entry:
ret i32 %call ret i32 %call
} }
; CHECK-LABEL: passFpConstArg ; CHECK-LABEL: passFpConstArg
; CALLTARGETS-LABEL: passFpConstArg
; CHECK: mov dword ptr [esp + 4], 123 ; CHECK: mov dword ptr [esp + 4], 123
; CHECK: call ignoreFpArgsNoInline ; CHECK: call -4
; CALLTARGETS: .long ignoreFpArgsNoInline
define internal i32 @passFp32ConstArg(float %a) { define internal i32 @passFp32ConstArg(float %a) {
entry: entry:
...@@ -191,7 +194,7 @@ entry: ...@@ -191,7 +194,7 @@ entry:
; CHECK-LABEL: remFloat ; CHECK-LABEL: remFloat
; CALLTARGETS-LABEL: remFloat ; CALLTARGETS-LABEL: remFloat
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call fmodf ; CALLTARGETS: .long fmodf
define internal double @remDouble(double %a, double %b) { define internal double @remDouble(double %a, double %b) {
entry: entry:
...@@ -201,7 +204,7 @@ entry: ...@@ -201,7 +204,7 @@ entry:
; CHECK-LABEL: remDouble ; CHECK-LABEL: remDouble
; CALLTARGETS-LABEL: remDouble ; CALLTARGETS-LABEL: remDouble
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call fmod ; CALLTARGETS: .long fmod
define internal float @fptrunc(double %a) { define internal float @fptrunc(double %a) {
entry: entry:
...@@ -229,7 +232,7 @@ entry: ...@@ -229,7 +232,7 @@ entry:
; CHECK-LABEL: doubleToSigned64 ; CHECK-LABEL: doubleToSigned64
; CALLTARGETS-LABEL: doubleToSigned64 ; CALLTARGETS-LABEL: doubleToSigned64
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call cvtdtosi64 ; CALLTARGETS: .long cvtdtosi64
define internal i64 @floatToSigned64(float %a) { define internal i64 @floatToSigned64(float %a) {
entry: entry:
...@@ -239,7 +242,7 @@ entry: ...@@ -239,7 +242,7 @@ entry:
; CHECK-LABEL: floatToSigned64 ; CHECK-LABEL: floatToSigned64
; CALLTARGETS-LABEL: floatToSigned64 ; CALLTARGETS-LABEL: floatToSigned64
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call cvtftosi64 ; CALLTARGETS: .long cvtftosi64
define internal i64 @doubleToUnsigned64(double %a) { define internal i64 @doubleToUnsigned64(double %a) {
entry: entry:
...@@ -249,7 +252,7 @@ entry: ...@@ -249,7 +252,7 @@ entry:
; CHECK-LABEL: doubleToUnsigned64 ; CHECK-LABEL: doubleToUnsigned64
; CALLTARGETS-LABEL: doubleToUnsigned64 ; CALLTARGETS-LABEL: doubleToUnsigned64
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call cvtdtoui64 ; CALLTARGETS: .long cvtdtoui64
define internal i64 @floatToUnsigned64(float %a) { define internal i64 @floatToUnsigned64(float %a) {
entry: entry:
...@@ -259,7 +262,7 @@ entry: ...@@ -259,7 +262,7 @@ entry:
; CHECK-LABEL: floatToUnsigned64 ; CHECK-LABEL: floatToUnsigned64
; CALLTARGETS-LABEL: floatToUnsigned64 ; CALLTARGETS-LABEL: floatToUnsigned64
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call cvtftoui64 ; CALLTARGETS: .long cvtftoui64
define internal i32 @doubleToSigned32(double %a) { define internal i32 @doubleToSigned32(double %a) {
entry: entry:
...@@ -293,7 +296,7 @@ entry: ...@@ -293,7 +296,7 @@ entry:
; CHECK-LABEL: doubleToUnsigned32 ; CHECK-LABEL: doubleToUnsigned32
; CALLTARGETS-LABEL: doubleToUnsigned32 ; CALLTARGETS-LABEL: doubleToUnsigned32
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call cvtdtoui32 ; CALLTARGETS: .long cvtdtoui32
define internal i32 @floatToUnsigned32(float %a) { define internal i32 @floatToUnsigned32(float %a) {
entry: entry:
...@@ -303,7 +306,7 @@ entry: ...@@ -303,7 +306,7 @@ entry:
; CHECK-LABEL: floatToUnsigned32 ; CHECK-LABEL: floatToUnsigned32
; CALLTARGETS-LABEL: floatToUnsigned32 ; CALLTARGETS-LABEL: floatToUnsigned32
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call cvtftoui32 ; CALLTARGETS: .long cvtftoui32
define internal i32 @doubleToSigned16(double %a) { define internal i32 @doubleToSigned16(double %a) {
...@@ -414,7 +417,7 @@ entry: ...@@ -414,7 +417,7 @@ entry:
; CHECK-LABEL: signed64ToDouble ; CHECK-LABEL: signed64ToDouble
; CALLTARGETS-LABEL: signed64ToDouble ; CALLTARGETS-LABEL: signed64ToDouble
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call cvtsi64tod ; CALLTARGETS: .long cvtsi64tod
; CHECK: fstp qword ; CHECK: fstp qword
define internal float @signed64ToFloat(i64 %a) { define internal float @signed64ToFloat(i64 %a) {
...@@ -425,7 +428,7 @@ entry: ...@@ -425,7 +428,7 @@ entry:
; CHECK-LABEL: signed64ToFloat ; CHECK-LABEL: signed64ToFloat
; CALLTARGETS-LABEL: signed64ToFloat ; CALLTARGETS-LABEL: signed64ToFloat
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call cvtsi64tof ; CALLTARGETS: .long cvtsi64tof
; CHECK: fstp dword ; CHECK: fstp dword
define internal double @unsigned64ToDouble(i64 %a) { define internal double @unsigned64ToDouble(i64 %a) {
...@@ -436,7 +439,7 @@ entry: ...@@ -436,7 +439,7 @@ entry:
; CHECK-LABEL: unsigned64ToDouble ; CHECK-LABEL: unsigned64ToDouble
; CALLTARGETS-LABEL: unsigned64ToDouble ; CALLTARGETS-LABEL: unsigned64ToDouble
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call cvtui64tod ; CALLTARGETS: .long cvtui64tod
; CHECK: fstp ; CHECK: fstp
define internal float @unsigned64ToFloat(i64 %a) { define internal float @unsigned64ToFloat(i64 %a) {
...@@ -447,7 +450,7 @@ entry: ...@@ -447,7 +450,7 @@ entry:
; CHECK-LABEL: unsigned64ToFloat ; CHECK-LABEL: unsigned64ToFloat
; CALLTARGETS-LABEL: unsigned64ToFloat ; CALLTARGETS-LABEL: unsigned64ToFloat
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call cvtui64tof ; CALLTARGETS: .long cvtui64tof
; CHECK: fstp ; CHECK: fstp
define internal double @unsigned64ToDoubleConst() { define internal double @unsigned64ToDoubleConst() {
...@@ -460,7 +463,7 @@ entry: ...@@ -460,7 +463,7 @@ entry:
; CHECK: mov dword ptr [esp + 4], 2874 ; CHECK: mov dword ptr [esp + 4], 2874
; CHECK: mov dword ptr [esp], 1942892530 ; CHECK: mov dword ptr [esp], 1942892530
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call cvtui64tod ; CALLTARGETS: .long cvtui64tod
; CHECK: fstp ; CHECK: fstp
define internal double @signed32ToDouble(i32 %a) { define internal double @signed32ToDouble(i32 %a) {
...@@ -498,7 +501,7 @@ entry: ...@@ -498,7 +501,7 @@ entry:
; CHECK-LABEL: unsigned32ToDouble ; CHECK-LABEL: unsigned32ToDouble
; CALLTARGETS-LABEL: unsigned32ToDouble ; CALLTARGETS-LABEL: unsigned32ToDouble
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call cvtui32tod ; CALLTARGETS: .long cvtui32tod
; CHECK: fstp qword ; CHECK: fstp qword
define internal float @unsigned32ToFloat(i32 %a) { define internal float @unsigned32ToFloat(i32 %a) {
...@@ -509,7 +512,7 @@ entry: ...@@ -509,7 +512,7 @@ entry:
; CHECK-LABEL: unsigned32ToFloat ; CHECK-LABEL: unsigned32ToFloat
; CALLTARGETS-LABEL: unsigned32ToFloat ; CALLTARGETS-LABEL: unsigned32ToFloat
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call cvtui32tof ; CALLTARGETS: .long cvtui32tof
; CHECK: fstp dword ; CHECK: fstp dword
define internal double @signed16ToDouble(i32 %a) { define internal double @signed16ToDouble(i32 %a) {
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
@global_char = internal global [1 x i8] zeroinitializer, align 1 @global_char = internal global [1 x i8] zeroinitializer, align 1
@p_global_char = internal global [4 x i8] zeroinitializer, align 4 @p_global_char = internal global [4 x i8] zeroinitializer, align 4
declare void @dummy(i32) declare void @dummy()
define internal void @store_immediate_to_global() { define internal void @store_immediate_to_global() {
entry: entry:
...@@ -48,8 +48,7 @@ entry: ...@@ -48,8 +48,7 @@ entry:
br i1 %cmp, label %if.then, label %if.end br i1 %cmp, label %if.then, label %if.end
if.then: ; preds = %entry if.then: ; preds = %entry
%dummy.bc = bitcast void (i32)* @dummy to void ()* tail call void @dummy()
tail call void %dummy.bc()
br label %if.end br label %if.end
if.end: ; preds = %if.then, %entry if.end: ; preds = %if.then, %entry
...@@ -58,4 +57,4 @@ if.end: ; preds = %if.then, %entry ...@@ -58,4 +57,4 @@ if.end: ; preds = %if.then, %entry
; CHECK-LABEL: cmp_global_immediate ; CHECK-LABEL: cmp_global_immediate
; CHECK: .long p_global_char ; CHECK: .long p_global_char
; CHECK: .long global_char ; CHECK: .long global_char
; CHECK: call dummy ; CHECK: .long dummy
...@@ -63,7 +63,7 @@ entry: ...@@ -63,7 +63,7 @@ entry:
; CHECKO2UNSANDBOXEDREM-LABEL: test_nacl_read_tp ; CHECKO2UNSANDBOXEDREM-LABEL: test_nacl_read_tp
; CHECKO2UNSANDBOXEDREM: call -4 ; CHECKO2UNSANDBOXEDREM: call -4
; CALLTARGETS-LABEL: test_nacl_read_tp ; CALLTARGETS-LABEL: test_nacl_read_tp
; CALLTARGETS: call __nacl_read_tp ; CALLTARGETS: .long __nacl_read_tp
define i32 @test_nacl_read_tp_more_addressing() { define i32 @test_nacl_read_tp_more_addressing() {
entry: entry:
...@@ -92,8 +92,8 @@ entry: ...@@ -92,8 +92,8 @@ entry:
; CHECKO2UNSANDBOXEDREM: call -4 ; CHECKO2UNSANDBOXEDREM: call -4
; CHECKO2UNSANDBOXEDREM: call -4 ; CHECKO2UNSANDBOXEDREM: call -4
; CALLTARGETS-LABEL: test_nacl_read_tp_more_addressing ; CALLTARGETS-LABEL: test_nacl_read_tp_more_addressing
; CALLTARGETS: call __nacl_read_tp ; CALLTARGETS: .long __nacl_read_tp
; CALLTARGETS: call __nacl_read_tp ; CALLTARGETS: .long __nacl_read_tp
define i32 @test_nacl_read_tp_dead(i32 %a) { define i32 @test_nacl_read_tp_dead(i32 %a) {
entry: entry:
...@@ -121,7 +121,7 @@ entry: ...@@ -121,7 +121,7 @@ entry:
; CHECK-LABEL: test_memcpy ; CHECK-LABEL: test_memcpy
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS-LABEL: test_memcpy ; CALLTARGETS-LABEL: test_memcpy
; CALLTARGETS: call memcpy ; CALLTARGETS: .long memcpy
; CHECKO2REM-LABEL: test_memcpy ; CHECKO2REM-LABEL: test_memcpy
; CHECKO2UNSANDBOXEDREM-LABEL: test_memcpy ; CHECKO2UNSANDBOXEDREM-LABEL: test_memcpy
...@@ -138,7 +138,7 @@ entry: ...@@ -138,7 +138,7 @@ entry:
; CHECK-LABEL: test_memcpy_const_len_align ; CHECK-LABEL: test_memcpy_const_len_align
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS-LABEL: test_memcpy_const_len_align ; CALLTARGETS-LABEL: test_memcpy_const_len_align
; CALLTARGETS: call memcpy ; CALLTARGETS: .long memcpy
define void @test_memmove(i32 %iptr_dst, i32 %iptr_src, i32 %len) { define void @test_memmove(i32 %iptr_dst, i32 %iptr_src, i32 %len) {
entry: entry:
...@@ -151,7 +151,7 @@ entry: ...@@ -151,7 +151,7 @@ entry:
; CHECK-LABEL: test_memmove ; CHECK-LABEL: test_memmove
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS-LABEL: test_memmove ; CALLTARGETS-LABEL: test_memmove
; CALLTARGETS: call memmove ; CALLTARGETS: .long memmove
define void @test_memmove_const_len_align(i32 %iptr_dst, i32 %iptr_src) { define void @test_memmove_const_len_align(i32 %iptr_dst, i32 %iptr_src) {
entry: entry:
...@@ -164,7 +164,7 @@ entry: ...@@ -164,7 +164,7 @@ entry:
; CHECK-LABEL: test_memmove_const_len_align ; CHECK-LABEL: test_memmove_const_len_align
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS-LABEL: test_memmove_const_len_align ; CALLTARGETS-LABEL: test_memmove_const_len_align
; CALLTARGETS: call memmove ; CALLTARGETS: .long memmove
define void @test_memset(i32 %iptr_dst, i32 %wide_val, i32 %len) { define void @test_memset(i32 %iptr_dst, i32 %wide_val, i32 %len) {
entry: entry:
...@@ -178,7 +178,7 @@ entry: ...@@ -178,7 +178,7 @@ entry:
; CHECK: movzx ; CHECK: movzx
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS-LABEL: test_memset ; CALLTARGETS-LABEL: test_memset
; CALLTARGETS: call memset ; CALLTARGETS: .long memset
define void @test_memset_const_len_align(i32 %iptr_dst, i32 %wide_val) { define void @test_memset_const_len_align(i32 %iptr_dst, i32 %wide_val) {
entry: entry:
...@@ -192,7 +192,7 @@ entry: ...@@ -192,7 +192,7 @@ entry:
; CHECK: movzx ; CHECK: movzx
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS-LABEL: test_memset_const_len_align ; CALLTARGETS-LABEL: test_memset_const_len_align
; CALLTARGETS: call memset ; CALLTARGETS: .long memset
define void @test_memset_const_val(i32 %iptr_dst, i32 %len) { define void @test_memset_const_val(i32 %iptr_dst, i32 %len) {
entry: entry:
...@@ -205,7 +205,7 @@ entry: ...@@ -205,7 +205,7 @@ entry:
; CHECK: movzx {{.*}}, {{[^0]}} ; CHECK: movzx {{.*}}, {{[^0]}}
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS-LABEL: test_memset_const_val ; CALLTARGETS-LABEL: test_memset_const_val
; CALLTARGETS: call memset ; CALLTARGETS: .long memset
define i32 @test_setjmplongjmp(i32 %iptr_env) { define i32 @test_setjmplongjmp(i32 %iptr_env) {
...@@ -229,8 +229,8 @@ NonZero: ...@@ -229,8 +229,8 @@ NonZero:
; CHECKO2REM: call -4 ; CHECKO2REM: call -4
; CHECKO2REM: call -4 ; CHECKO2REM: call -4
; CALLTARGETS-LABEL: test_setjmplongjmp ; CALLTARGETS-LABEL: test_setjmplongjmp
; CALLTARGETS: call setjmp ; CALLTARGETS: .long setjmp
; CALLTARGETS: call longjmp ; CALLTARGETS: .long longjmp
define i32 @test_setjmp_unused(i32 %iptr_env, i32 %i_other) { define i32 @test_setjmp_unused(i32 %iptr_env, i32 %i_other) {
entry: entry:
...@@ -243,7 +243,7 @@ entry: ...@@ -243,7 +243,7 @@ entry:
; CHECKO2REM-LABEL: test_setjmp_unused ; CHECKO2REM-LABEL: test_setjmp_unused
; CHECKO2REM: call -4 ; CHECKO2REM: call -4
; CALLTARGETS-LABEL: test_setjmp_unused ; CALLTARGETS-LABEL: test_setjmp_unused
; CALLTARGETS: call setjmp ; CALLTARGETS: .long setjmp
define float @test_sqrt_float(float %x, i32 %iptr) { define float @test_sqrt_float(float %x, i32 %iptr) {
entry: entry:
...@@ -451,7 +451,7 @@ entry: ...@@ -451,7 +451,7 @@ entry:
; CHECK-LABEL: test_popcount_32 ; CHECK-LABEL: test_popcount_32
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS-LABEL: test_popcount_32 ; CALLTARGETS-LABEL: test_popcount_32
; CALLTARGETS: call __popcountsi2 ; CALLTARGETS: .long __popcountsi2
define i64 @test_popcount_64(i64 %x) { define i64 @test_popcount_64(i64 %x) {
entry: entry:
...@@ -464,7 +464,7 @@ entry: ...@@ -464,7 +464,7 @@ entry:
; the return value just in case. ; the return value just in case.
; CHECK: mov {{.*}}, 0 ; CHECK: mov {{.*}}, 0
; CALLTARGETS-LABEL: test_popcount_64 ; CALLTARGETS-LABEL: test_popcount_64
; CALLTARGETS: call __popcountdi2 ; CALLTARGETS: .long __popcountdi2
define i32 @test_popcount_64_ret_i32(i64 %x) { define i32 @test_popcount_64_ret_i32(i64 %x) {
...@@ -478,7 +478,7 @@ entry: ...@@ -478,7 +478,7 @@ entry:
; CHECKO2REM: call -4 ; CHECKO2REM: call -4
; CHECKO2REM-NOT: mov {{.*}}, 0 ; CHECKO2REM-NOT: mov {{.*}}, 0
; CALLTARGETS-LABEL: test_popcount_64_ret_i32 ; CALLTARGETS-LABEL: test_popcount_64_ret_i32
; CALLTARGETS: call __popcountdi2 ; CALLTARGETS: .long __popcountdi2
define void @test_stacksave_noalloca() { define void @test_stacksave_noalloca() {
entry: entry:
......
...@@ -30,7 +30,7 @@ return: ; preds = %entry ...@@ -30,7 +30,7 @@ return: ; preds = %entry
; CALLTARGETS-LABEL: divide ; CALLTARGETS-LABEL: divide
; CHECK: cmp ; CHECK: cmp
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call ice_unreachable ; CALLTARGETS: .long ice_unreachable
; CHECK: cdq ; CHECK: cdq
; CHECK: idiv ; CHECK: idiv
; CHECK: ret ; CHECK: ret
...@@ -167,7 +167,7 @@ entry: ...@@ -167,7 +167,7 @@ entry:
; CHECK-LABEL: test_bitcast_v8i1_to_i8: ; CHECK-LABEL: test_bitcast_v8i1_to_i8:
; CALLTARGETS-LABEL: test_bitcast_v8i1_to_i8: ; CALLTARGETS-LABEL: test_bitcast_v8i1_to_i8:
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call Sz_bitcast_v8i1_to_i8 ; CALLTARGETS: .long Sz_bitcast_v8i1_to_i8
; OPTM1-LABEL: test_bitcast_v8i1_to_i8: ; OPTM1-LABEL: test_bitcast_v8i1_to_i8:
; OPMT1: call -4 ; OPMT1: call -4
...@@ -181,7 +181,7 @@ entry: ...@@ -181,7 +181,7 @@ entry:
; CHECK-LABEL: test_bitcast_v16i1_to_i16: ; CHECK-LABEL: test_bitcast_v16i1_to_i16:
; CALLTARGETS-LABEL: test_bitcast_v16i1_to_i16: ; CALLTARGETS-LABEL: test_bitcast_v16i1_to_i16:
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call Sz_bitcast_v16i1_to_i16 ; CALLTARGETS: .long Sz_bitcast_v16i1_to_i16
; OPTM1-LABEL: test_bitcast_v16i1_to_i16: ; OPTM1-LABEL: test_bitcast_v16i1_to_i16:
; OPMT1: call -4 ; OPMT1: call -4
...@@ -196,7 +196,7 @@ entry: ...@@ -196,7 +196,7 @@ entry:
; CHECK-LABEL: test_bitcast_i8_to_v8i1: ; CHECK-LABEL: test_bitcast_i8_to_v8i1:
; CALLTARGETS-LABEL: test_bitcast_i8_to_v8i1 ; CALLTARGETS-LABEL: test_bitcast_i8_to_v8i1
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call Sz_bitcast_i8_to_v8i1 ; CALLTARGETS: .long Sz_bitcast_i8_to_v8i1
; OPTM1-LABEL: test_bitcast_i8_to_v8i1: ; OPTM1-LABEL: test_bitcast_i8_to_v8i1:
; OPTM1: call -4 ; OPTM1: call -4
...@@ -211,7 +211,7 @@ entry: ...@@ -211,7 +211,7 @@ entry:
; CHECK-LABEL: test_bitcast_i16_to_v16i1: ; CHECK-LABEL: test_bitcast_i16_to_v16i1:
; CALLTARGETS-LABEL: test_bitcast_i16_to_v16i1 ; CALLTARGETS-LABEL: test_bitcast_i16_to_v16i1
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS: call Sz_bitcast_i16_to_v16i1 ; CALLTARGETS: .long Sz_bitcast_i16_to_v16i1
; OPTM1-LABEL: test_bitcast_i16_to_v16i1: ; OPTM1-LABEL: test_bitcast_i16_to_v16i1:
; OPTM1: call -4 ; OPTM1: call -4
......
...@@ -145,7 +145,7 @@ entry: ...@@ -145,7 +145,7 @@ entry:
; CHECK-LABEL: test_fptoui_v4f32_to_v4i32: ; CHECK-LABEL: test_fptoui_v4f32_to_v4i32:
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS-LABEL: test_fptoui_v4f32_to_v4i32 ; CALLTARGETS-LABEL: test_fptoui_v4f32_to_v4i32
; CALLTARGETS: call Sz_fptoui_v4f32 ; CALLTARGETS: .long Sz_fptoui_v4f32
} }
; [su]itofp operations ; [su]itofp operations
...@@ -167,5 +167,5 @@ entry: ...@@ -167,5 +167,5 @@ entry:
; CHECK-LABEL: test_uitofp_v4i32_to_v4f32: ; CHECK-LABEL: test_uitofp_v4i32_to_v4f32:
; CHECK: call -4 ; CHECK: call -4
; CALLTARGETS-LABEL: test_uitofp_v4i32_to_v4f32 ; CALLTARGETS-LABEL: test_uitofp_v4i32_to_v4f32
; CALLTARGETS: call Sz_uitofp_v4i32 ; CALLTARGETS: .long Sz_uitofp_v4i32
} }
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