[ms-inline asm] Refactor code so that we can begin computing the Inputs/Outputs.

No functional change intended.

llvm-svn: 162403
This commit is contained in:
Chad Rosier 2012-08-22 22:10:51 +00:00
parent df38adae0f
commit dc5311aab6
1 changed files with 19 additions and 11 deletions

View File

@ -546,20 +546,28 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc,
TheTarget->createMCInstPrinter(1, *MAI, *MII, *MRI, *STI); TheTarget->createMCInstPrinter(1, *MAI, *MII, *MRI, *STI);
// Build the list of clobbers. // Build the list of clobbers.
for (unsigned i = 0, e = Desc.getNumDefs(); i != e; ++i) { unsigned NumDefs = Desc.getNumDefs();
const llvm::MCOperand &Op = Inst.getOperand(i); for (unsigned j = 0, e = Inst.getNumOperands(); j != e; ++j) {
if (!Op.isReg()) const llvm::MCOperand &Op = Inst.getOperand(j);
// Immediate.
if (Op.isImm() || Op.isFPImm())
continue; continue;
std::string Reg; bool isDef = NumDefs && (j < NumDefs);
llvm::raw_string_ostream OS(Reg);
IP->printRegName(OS, Op.getReg());
StringRef Clobber(OS.str()); // Register/Clobber.
if (!Context.getTargetInfo().isValidClobber(Clobber)) if (Op.isReg() && isDef) {
return StmtError(Diag(AsmLoc, diag::err_asm_unknown_register_name) << std::string Reg;
Clobber); llvm::raw_string_ostream OS(Reg);
ClobberRegs.insert(Reg); IP->printRegName(OS, Op.getReg());
StringRef Clobber(OS.str());
if (!Context.getTargetInfo().isValidClobber(Clobber))
return StmtError(Diag(AsmLoc, diag::err_asm_unknown_register_name) <<
Clobber);
ClobberRegs.insert(Reg);
}
} }
} }
for (std::set<std::string>::iterator I = ClobberRegs.begin(), for (std::set<std::string>::iterator I = ClobberRegs.begin(),