Commit 58eeedf7 by Jaydeep Patil Committed by Jim Stichnoth

Subzero, MIPS32: Binding intrablock labels, unconditional branch

This patch was supposed to be a part of patch with instruction encodings. R=stichnot@chromium.org Review URL: https://codereview.chromium.org/2367743004 . Patch from Jaydeep Patil <jaydeep.patil@imgtec.com>. Author: Jaydeep Patil
parent 4c49b108
...@@ -301,6 +301,16 @@ public: ...@@ -301,6 +301,16 @@ public:
return getOrCreateLabel(Number, LocalLabels); return getOrCreateLabel(Number, LocalLabels);
} }
void bindLocalLabel(const InstMIPS32Label *InstL, SizeT Number) {
if (BuildDefs::dump() && !getFlags().getDisableHybridAssembly()) {
constexpr SizeT InstSize = 0;
emitTextInst(InstL->getLabelName() + ":", InstSize);
}
Label *L = getOrCreateLocalLabel(Number);
if (!getPreliminary())
this->bind(L);
}
bool fixupIsPCRel(FixupKind Kind) const override { bool fixupIsPCRel(FixupKind Kind) const override {
(void)Kind; (void)Kind;
llvm::report_fatal_error("Not yet implemented."); llvm::report_fatal_error("Not yet implemented.");
......
...@@ -273,8 +273,8 @@ void InstMIPS32Label::emit(const Cfg *Func) const { ...@@ -273,8 +273,8 @@ void InstMIPS32Label::emit(const Cfg *Func) const {
} }
void InstMIPS32Label::emitIAS(const Cfg *Func) const { void InstMIPS32Label::emitIAS(const Cfg *Func) const {
(void)Func; auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
llvm_unreachable("Not yet implemented"); Asm->bindLocalLabel(this, Number);
} }
InstMIPS32Call::InstMIPS32Call(Cfg *Func, Variable *Dest, Operand *CallTarget) InstMIPS32Call::InstMIPS32Call(Cfg *Func, Variable *Dest, Operand *CallTarget)
...@@ -419,7 +419,11 @@ void InstMIPS32Ret::emit(const Cfg *Func) const { ...@@ -419,7 +419,11 @@ void InstMIPS32Ret::emit(const Cfg *Func) const {
void InstMIPS32Br::emitIAS(const Cfg *Func) const { void InstMIPS32Br::emitIAS(const Cfg *Func) const {
auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>(); auto *Asm = Func->getAssembler<MIPS32::AssemblerMIPS32>();
if (isUnconditionalBranch()) { if (Label != nullptr) {
// Intra-block branches are of kind bcc
Asm->bcc(Predicate, getSrc(0), getSrc(1),
Asm->getOrCreateLocalLabel(Label->getNumber()));
} else if (isUnconditionalBranch()) {
Asm->b(Asm->getOrCreateCfgNodeLabel(getTargetFalse()->getIndex())); Asm->b(Asm->getOrCreateCfgNodeLabel(getTargetFalse()->getIndex()));
} else { } else {
switch (Predicate) { switch (Predicate) {
...@@ -440,6 +444,9 @@ void InstMIPS32Br::emitIAS(const Cfg *Func) const { ...@@ -440,6 +444,9 @@ void InstMIPS32Br::emitIAS(const Cfg *Func) const {
Asm->getOrCreateCfgNodeLabel(getTargetFalse()->getIndex())); Asm->getOrCreateCfgNodeLabel(getTargetFalse()->getIndex()));
break; break;
} }
if (getTargetTrue()) {
Asm->b(Asm->getOrCreateCfgNodeLabel(getTargetTrue()->getIndex()));
}
} }
} }
......
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