Use IdentifierInfo * instead of std::string for the AsmStmt names.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94925 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anders Carlsson 2010-01-30 22:25:16 +00:00
Родитель 807b06157a
Коммит ff93dbd887
11 изменённых файлов: 54 добавлений и 34 удалений

Просмотреть файл

@ -1121,7 +1121,7 @@ class AsmStmt : public Stmt {
unsigned NumOutputs;
unsigned NumInputs;
llvm::SmallVector<std::string, 4> Names;
llvm::SmallVector<IdentifierInfo *, 4> Names;
llvm::SmallVector<StringLiteral*, 4> Constraints;
llvm::SmallVector<Stmt*, 4> Exprs;
@ -1129,7 +1129,7 @@ class AsmStmt : public Stmt {
public:
AsmStmt(SourceLocation asmloc, bool issimple, bool isvolatile, bool msasm,
unsigned numoutputs, unsigned numinputs,
const std::string *names, StringLiteral **constraints,
IdentifierInfo **names, StringLiteral **constraints,
Expr **exprs, StringLiteral *asmstr, unsigned numclobbers,
StringLiteral **clobbers, SourceLocation rparenloc);
@ -1208,10 +1208,17 @@ public:
unsigned getNumOutputs() const { return NumOutputs; }
const std::string &getOutputName(unsigned i) const {
IdentifierInfo *getOutputIdentifier(unsigned i) const {
return Names[i];
}
llvm::StringRef getOutputName(unsigned i) const {
if (IdentifierInfo *II = getOutputIdentifier(i))
return II->getName();
return llvm::StringRef();
}
/// getOutputConstraint - Return the constraint string for the specified
/// output operand. All output constraints are known to be non-empty (either
/// '=' or '+').
@ -1224,7 +1231,6 @@ public:
return Constraints[i];
}
Expr *getOutputExpr(unsigned i);
const Expr *getOutputExpr(unsigned i) const {
@ -1246,10 +1252,17 @@ public:
unsigned getNumInputs() const { return NumInputs; }
const std::string &getInputName(unsigned i) const {
IdentifierInfo *getInputIdentifier(unsigned i) const {
return Names[i + NumOutputs];
}
llvm::StringRef getInputName(unsigned i) const {
if (IdentifierInfo *II = getInputIdentifier(i))
return II->getName();
return llvm::StringRef();
}
/// getInputConstraint - Return the specified input constraint. Unlike output
/// constraints, these can be empty.
llvm::StringRef getInputConstraint(unsigned i) const;
@ -1268,7 +1281,7 @@ public:
}
void setOutputsAndInputsAndClobbers(ASTContext &C,
const std::string *Names,
IdentifierInfo **Names,
StringLiteral **Constraints,
Stmt **Exprs,
unsigned NumOutputs,

Просмотреть файл

@ -902,7 +902,7 @@ public:
bool IsVolatile,
unsigned NumOutputs,
unsigned NumInputs,
const std::string *Names,
IdentifierInfo **Names,
MultiExprArg Constraints,
MultiExprArg Exprs,
ExprArg AsmString,

Просмотреть файл

@ -1009,9 +1009,9 @@ private:
OwningStmtResult ParseReturnStatement(AttributeList *Attr);
OwningStmtResult ParseAsmStatement(bool &msAsm);
OwningStmtResult FuzzyParseMicrosoftAsmStatement();
bool ParseAsmOperandsOpt(llvm::SmallVectorImpl<std::string> &Names,
llvm::SmallVectorImpl<ExprTy*> &Constraints,
llvm::SmallVectorImpl<ExprTy*> &Exprs);
bool ParseAsmOperandsOpt(llvm::SmallVectorImpl<IdentifierInfo *> &Names,
llvm::SmallVectorImpl<ExprTy *> &Constraints,
llvm::SmallVectorImpl<ExprTy *> &Exprs);
//===--------------------------------------------------------------------===//
// C++ 6: Statements and Blocks

Просмотреть файл

@ -158,7 +158,7 @@ llvm::StringRef AsmStmt::getInputConstraint(unsigned i) const {
void AsmStmt::setOutputsAndInputsAndClobbers(ASTContext &C,
const std::string *Names,
IdentifierInfo **Names,
StringLiteral **Constraints,
Stmt **Exprs,
unsigned NumOutputs,
@ -335,7 +335,7 @@ unsigned AsmStmt::AnalyzeAsmString(llvm::SmallVectorImpl<AsmStringPiece>&Pieces,
AsmStmt::AsmStmt(SourceLocation asmloc, bool issimple, bool isvolatile,
bool msasm, unsigned numoutputs, unsigned numinputs,
const std::string *names, StringLiteral **constraints,
IdentifierInfo **names, StringLiteral **constraints,
Expr **exprs, StringLiteral *asmstr, unsigned numclobbers,
StringLiteral **clobbers, SourceLocation rparenloc)
: Stmt(AsmStmtClass), AsmLoc(asmloc), RParenLoc(rparenloc), AsmStr(asmstr)

Просмотреть файл

@ -317,11 +317,11 @@ unsigned PCHStmtReader::VisitAsmStmt(AsmStmt *S) {
S->setAsmString(cast_or_null<StringLiteral>(StmtStack[StackIdx++]));
// Outputs and inputs
llvm::SmallVector<std::string, 16> Names;
llvm::SmallVector<IdentifierInfo *, 16> Names;
llvm::SmallVector<StringLiteral*, 16> Constraints;
llvm::SmallVector<Stmt*, 16> Exprs;
for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
Names.push_back(Reader.ReadString(Record, Idx));
Names.push_back(Reader.GetIdentifierInfo(Record, Idx));
Constraints.push_back(cast_or_null<StringLiteral>(StmtStack[StackIdx++]));
Exprs.push_back(StmtStack[StackIdx++]);
}

Просмотреть файл

@ -287,15 +287,15 @@ void PCHStmtWriter::VisitAsmStmt(AsmStmt *S) {
Writer.WriteSubStmt(S->getAsmString());
// Outputs
for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
Writer.AddString(S->getOutputName(I), Record);
for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
Writer.AddIdentifierRef(S->getOutputIdentifier(I), Record);
Writer.WriteSubStmt(S->getOutputConstraintLiteral(I));
Writer.WriteSubStmt(S->getOutputExpr(I));
}
// Inputs
for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
Writer.AddString(S->getInputName(I), Record);
Writer.AddIdentifierRef(S->getInputIdentifier(I), Record);
Writer.WriteSubStmt(S->getInputConstraintLiteral(I));
Writer.WriteSubStmt(S->getInputExpr(I));
}

Просмотреть файл

@ -391,7 +391,7 @@ namespace {
bool IsVolatile,
unsigned NumOutputs,
unsigned NumInputs,
const std::string *Names,
IdentifierInfo **Names,
MultiExprArg Constraints,
MultiExprArg Exprs,
ExprArg AsmString,

Просмотреть файл

@ -1171,7 +1171,6 @@ Parser::OwningStmtResult Parser::FuzzyParseMicrosoftAsmStatement() {
Tok.isNot(tok::r_brace) && Tok.isNot(tok::semi) &&
Tok.isNot(tok::eof));
}
llvm::SmallVector<std::string, 4> Names;
Token t;
t.setKind(tok::string_literal);
t.setLiteralData("\"FIXME: not done\"");
@ -1181,7 +1180,7 @@ Parser::OwningStmtResult Parser::FuzzyParseMicrosoftAsmStatement() {
ExprVector Constraints(Actions);
ExprVector Exprs(Actions);
ExprVector Clobbers(Actions);
return Actions.ActOnAsmStmt(Tok.getLocation(), true, true, 0, 0, Names.data(),
return Actions.ActOnAsmStmt(Tok.getLocation(), true, true, 0, 0, 0,
move_arg(Constraints), move_arg(Exprs),
move(AsmString), move_arg(Clobbers),
Tok.getLocation(), true);
@ -1245,7 +1244,7 @@ Parser::OwningStmtResult Parser::ParseAsmStatement(bool &msAsm) {
if (AsmString.isInvalid())
return StmtError();
llvm::SmallVector<std::string, 4> Names;
llvm::SmallVector<IdentifierInfo *, 4> Names;
ExprVector Constraints(Actions);
ExprVector Exprs(Actions);
ExprVector Clobbers(Actions);
@ -1336,9 +1335,9 @@ Parser::OwningStmtResult Parser::ParseAsmStatement(bool &msAsm) {
///
//
// FIXME: Avoid unnecessary std::string trashing.
bool Parser::ParseAsmOperandsOpt(llvm::SmallVectorImpl<std::string> &Names,
llvm::SmallVectorImpl<ExprTy*> &Constraints,
llvm::SmallVectorImpl<ExprTy*> &Exprs) {
bool Parser::ParseAsmOperandsOpt(llvm::SmallVectorImpl<IdentifierInfo *> &Names,
llvm::SmallVectorImpl<ExprTy *> &Constraints,
llvm::SmallVectorImpl<ExprTy *> &Exprs) {
// 'asm-operands' isn't present?
if (!isTokenStringLiteral() && Tok.isNot(tok::l_square))
return false;
@ -1357,10 +1356,10 @@ bool Parser::ParseAsmOperandsOpt(llvm::SmallVectorImpl<std::string> &Names,
IdentifierInfo *II = Tok.getIdentifierInfo();
ConsumeToken();
Names.push_back(II->getName());
Names.push_back(II);
MatchRHSPunctuation(tok::r_square, Loc);
} else
Names.push_back(std::string());
Names.push_back(0);
OwningExprResult Constraint(ParseAsmStringLiteral());
if (Constraint.isInvalid()) {

Просмотреть файл

@ -1478,7 +1478,7 @@ public:
bool IsVolatile,
unsigned NumOutputs,
unsigned NumInputs,
const std::string *Names,
IdentifierInfo **Names,
MultiExprArg Constraints,
MultiExprArg Exprs,
ExprArg AsmString,

Просмотреть файл

@ -1170,7 +1170,7 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
bool IsVolatile,
unsigned NumOutputs,
unsigned NumInputs,
const std::string *Names,
IdentifierInfo **Names,
MultiExprArg constraints,
MultiExprArg exprs,
ExprArg asmString,
@ -1197,7 +1197,11 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
return StmtError(Diag(Literal->getLocStart(),diag::err_asm_wide_character)
<< Literal->getSourceRange());
TargetInfo::ConstraintInfo Info(Literal->getString(), Names[i]);
llvm::StringRef OutputName;
if (Names[i])
OutputName = Names[i]->getName();
TargetInfo::ConstraintInfo Info(Literal->getString(), OutputName);
if (!Context.Target.validateOutputConstraint(Info))
return StmtError(Diag(Literal->getLocStart(),
diag::err_asm_invalid_output_constraint)
@ -1222,7 +1226,11 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
return StmtError(Diag(Literal->getLocStart(),diag::err_asm_wide_character)
<< Literal->getSourceRange());
TargetInfo::ConstraintInfo Info(Literal->getString(), Names[i]);
llvm::StringRef InputName;
if (Names[i])
InputName = Names[i]->getName();
TargetInfo::ConstraintInfo Info(Literal->getString(), InputName);
if (!Context.Target.validateInputConstraint(OutputConstraintInfos.data(),
NumOutputs, Info)) {
return StmtError(Diag(Literal->getLocStart(),

Просмотреть файл

@ -785,7 +785,7 @@ public:
bool IsVolatile,
unsigned NumOutputs,
unsigned NumInputs,
const std::string *Names,
IdentifierInfo **Names,
MultiExprArg Constraints,
MultiExprArg Exprs,
ExprArg AsmString,
@ -3352,7 +3352,7 @@ TreeTransform<Derived>::TransformAsmStmt(AsmStmt *S) {
ASTOwningVector<&ActionBase::DeleteExpr> Constraints(getSema());
ASTOwningVector<&ActionBase::DeleteExpr> Exprs(getSema());
llvm::SmallVector<std::string, 4> Names;
llvm::SmallVector<IdentifierInfo *, 4> Names;
OwningExprResult AsmString(SemaRef);
ASTOwningVector<&ActionBase::DeleteExpr> Clobbers(getSema());
@ -3361,7 +3361,7 @@ TreeTransform<Derived>::TransformAsmStmt(AsmStmt *S) {
// Go through the outputs.
for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
Names.push_back(S->getOutputName(I));
Names.push_back(S->getOutputIdentifier(I));
// No need to transform the constraint literal.
Constraints.push_back(S->getOutputConstraintLiteral(I)->Retain());
@ -3379,7 +3379,7 @@ TreeTransform<Derived>::TransformAsmStmt(AsmStmt *S) {
// Go through the inputs.
for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
Names.push_back(S->getInputName(I));
Names.push_back(S->getInputIdentifier(I));
// No need to transform the constraint literal.
Constraints.push_back(S->getInputConstraintLiteral(I)->Retain());