[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);
// Build the list of clobbers.
for (unsigned i = 0, e = Desc.getNumDefs(); i != e; ++i) {
const llvm::MCOperand &Op = Inst.getOperand(i);
if (!Op.isReg())
unsigned NumDefs = Desc.getNumDefs();
for (unsigned j = 0, e = Inst.getNumOperands(); j != e; ++j) {
const llvm::MCOperand &Op = Inst.getOperand(j);
// Immediate.
if (Op.isImm() || Op.isFPImm())
continue;
std::string Reg;
llvm::raw_string_ostream OS(Reg);
IP->printRegName(OS, Op.getReg());
bool isDef = NumDefs && (j < NumDefs);
StringRef Clobber(OS.str());
if (!Context.getTargetInfo().isValidClobber(Clobber))
return StmtError(Diag(AsmLoc, diag::err_asm_unknown_register_name) <<
Clobber);
ClobberRegs.insert(Reg);
// Register/Clobber.
if (Op.isReg() && isDef) {
std::string Reg;
llvm::raw_string_ostream OS(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(),