Make Intel syntax mode friendlier to Microsoft ML assembler (still needs more work).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28044 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jeff Cohen
2006-05-02 01:16:28 +00:00
parent eff5c36238
commit c884db47f1
4 changed files with 119 additions and 28 deletions

View File

@@ -372,6 +372,21 @@ static void printAsCString(std::ostream &O, const ConstantArray *CVA,
O << "\"";
}
/// EmitString - Emit a zero-byte-terminated string constant.
///
void AsmPrinter::EmitString(const ConstantArray *CVA) const {
unsigned NumElts = CVA->getNumOperands();
if (AscizDirective && NumElts &&
cast<ConstantInt>(CVA->getOperand(NumElts-1))->getRawValue() == 0) {
O << AscizDirective;
printAsCString(O, CVA, NumElts-1);
} else {
O << AsciiDirective;
printAsCString(O, CVA, NumElts);
}
O << "\n";
}
/// EmitGlobalConstant - Print a general LLVM constant to the .s file.
///
void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
@@ -382,16 +397,7 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
return;
} else if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV)) {
if (CVA->isString()) {
unsigned NumElts = CVA->getNumOperands();
if (AscizDirective && NumElts &&
cast<ConstantInt>(CVA->getOperand(NumElts-1))->getRawValue() == 0) {
O << AscizDirective;
printAsCString(O, CVA, NumElts-1);
} else {
O << AsciiDirective;
printAsCString(O, CVA, NumElts);
}
O << "\n";
EmitString(CVA);
} else { // Not a string. Print the values in successive locations
for (unsigned i = 0, e = CVA->getNumOperands(); i != e; ++i)
EmitGlobalConstant(CVA->getOperand(i));