本文整理汇总了C++中formatted_raw_ostream类的典型用法代码示例。如果您正苦于以下问题:C++ formatted_raw_ostream类的具体用法?C++ formatted_raw_ostream怎么用?C++ formatted_raw_ostream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了formatted_raw_ostream类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: expandCheckOpcode
void PredicateExpander::expandCheckOpcode(formatted_raw_ostream &OS,
const RecVec &Opcodes) {
assert(!Opcodes.empty() && "Expected at least one opcode to check!");
bool First = true;
if (Opcodes.size() == 1) {
OS << "( ";
expandCheckOpcode(OS, Opcodes[0]);
OS << " )";
return;
}
OS << '(';
increaseIndentLevel();
for (const Record *Rec : Opcodes) {
OS << '\n';
OS.PadToColumn(getIndentLevel() * 2);
if (!First)
OS << (shouldNegate() ? "&& " : "|| ");
expandCheckOpcode(OS, Rec);
First = false;
}
OS << '\n';
decreaseIndentLevel();
OS.PadToColumn(getIndentLevel() * 2);
OS << ')';
}
开发者ID:bkaradzic,项目名称:SwiftShader,代码行数:29,代码来源:PredicateExpander.cpp
示例2: expandPredicateSequence
void PredicateExpander::expandPredicateSequence(formatted_raw_ostream &OS,
const RecVec &Sequence,
bool IsCheckAll) {
assert(!Sequence.empty() && "Found an invalid empty predicate set!");
if (Sequence.size() == 1)
return expandPredicate(OS, Sequence[0]);
// Okay, there is more than one predicate in the set.
bool First = true;
OS << (shouldNegate() ? "!(" : "(");
increaseIndentLevel();
bool OldValue = shouldNegate();
setNegatePredicate(false);
for (const Record *Rec : Sequence) {
OS << '\n';
OS.PadToColumn(getIndentLevel() * 2);
if (!First)
OS << (IsCheckAll ? "&& " : "|| ");
expandPredicate(OS, Rec);
First = false;
}
OS << '\n';
decreaseIndentLevel();
OS.PadToColumn(getIndentLevel() * 2);
OS << ')';
setNegatePredicate(OldValue);
}
开发者ID:bkaradzic,项目名称:SwiftShader,代码行数:28,代码来源:PredicateExpander.cpp
示例3: emitComments
/// \brief Emits the comments that are stored in \p DC comment stream.
/// Each comment in the comment stream must end with a newline.
static void emitComments(LLVMDisasmContext *DC,
formatted_raw_ostream &FormattedOS) {
// Flush the stream before taking its content.
DC->CommentStream.flush();
StringRef Comments = DC->CommentsToEmit.str();
// Get the default information for printing a comment.
const MCAsmInfo *MAI = DC->getAsmInfo();
const char *CommentBegin = MAI->getCommentString();
unsigned CommentColumn = MAI->getCommentColumn();
bool IsFirst = true;
while (!Comments.empty()) {
if (!IsFirst)
FormattedOS << '\n';
// Emit a line of comments.
FormattedOS.PadToColumn(CommentColumn);
size_t Position = Comments.find('\n');
FormattedOS << CommentBegin << ' ' << Comments.substr(0, Position);
// Move after the newline character.
Comments = Comments.substr(Position+1);
IsFirst = false;
}
FormattedOS.flush();
// Tell the comment stream that the vector changed underneath it.
DC->CommentsToEmit.clear();
DC->CommentStream.resync();
}
开发者ID:ADonut,项目名称:LLVM-GPGPU,代码行数:29,代码来源:Disassembler.cpp
示例4: printInstruction
void Disassembler::printInstruction(formatted_raw_ostream &Out,
MachineInstr *Inst, bool PrintTypes) {
unsigned Address = getDebugOffset(Inst->getDebugLoc());
unsigned Size = Inst->getDesc().getSize();
// TODO: replace the Bytes with something memory safe (StringRef??)
uint8_t *Bytes = new uint8_t(Size);
int NumRead = CurSectionMemory->readBytes(Address, Size, Bytes);
if (NumRead < 0) {
printError("Unable to read current section memory!");
return;
}
// Print Address
Out << format("%08" PRIX64 ":", Address);
Out.PadToColumn(12); // 12345678: <- 9 chars + 1 space
// Print Instruction Bytes
for (unsigned i = 0, e = ((Size > 8) ? 8 : Size); i != e; ++i)
Out << format("%02" PRIX8 " ", Bytes[i]);
Out.PadToColumn(40); // 8 bytes (2 char) + 1 space each + 2 spaces
// Print instruction
// NOTE: We could print the "Full" machine instruction version here instead
// of down-converting to MCInst...
if (PrintTypes) {
Inst->print(Out, MC->getTargetMachine(), false);
} else {
MC->getMCInstPrinter()->printInst(Instructions[Address], Out, "");
Out << "\n";
}
// Print the rest of the instruction bytes
unsigned ColCnt = 8;
for (unsigned i = 8, e = Size; i < e; ++i) {
if (ColCnt == 8) {
Out.PadToColumn(12); // 8 bytes (2 char) + 1 space each + 2 spaces
Out << "\n";
ColCnt = 0;
} else {
++ColCnt;
}
Out << format("%02" PRIX8 " ", Bytes[i]);
}
delete Bytes;
}
开发者ID:SAB2012,项目名称:fracture,代码行数:44,代码来源:Disassembler.cpp
示例5: EmitHistogram
void MatcherTableEmitter::EmitHistogram(const Matcher *M,
formatted_raw_ostream &OS) {
if (OmitComments)
return;
std::vector<unsigned> OpcodeFreq;
BuildHistogram(M, OpcodeFreq);
OS << " // Opcode Histogram:\n";
for (unsigned i = 0, e = OpcodeFreq.size(); i != e; ++i) {
OS << " // #";
switch ((Matcher::KindTy)i) {
case Matcher::Scope: OS << "OPC_Scope"; break;
case Matcher::RecordNode: OS << "OPC_RecordNode"; break;
case Matcher::RecordChild: OS << "OPC_RecordChild"; break;
case Matcher::RecordMemRef: OS << "OPC_RecordMemRef"; break;
case Matcher::CaptureGlueInput: OS << "OPC_CaptureGlueInput"; break;
case Matcher::MoveChild: OS << "OPC_MoveChild"; break;
case Matcher::MoveParent: OS << "OPC_MoveParent"; break;
case Matcher::CheckSame: OS << "OPC_CheckSame"; break;
case Matcher::CheckChildSame: OS << "OPC_CheckChildSame"; break;
case Matcher::CheckPatternPredicate:
OS << "OPC_CheckPatternPredicate"; break;
case Matcher::CheckPredicate: OS << "OPC_CheckPredicate"; break;
case Matcher::CheckOpcode: OS << "OPC_CheckOpcode"; break;
case Matcher::SwitchOpcode: OS << "OPC_SwitchOpcode"; break;
case Matcher::CheckType: OS << "OPC_CheckType"; break;
case Matcher::SwitchType: OS << "OPC_SwitchType"; break;
case Matcher::CheckChildType: OS << "OPC_CheckChildType"; break;
case Matcher::CheckInteger: OS << "OPC_CheckInteger"; break;
case Matcher::CheckChildInteger: OS << "OPC_CheckChildInteger"; break;
case Matcher::CheckCondCode: OS << "OPC_CheckCondCode"; break;
case Matcher::CheckValueType: OS << "OPC_CheckValueType"; break;
case Matcher::CheckComplexPat: OS << "OPC_CheckComplexPat"; break;
case Matcher::CheckAndImm: OS << "OPC_CheckAndImm"; break;
case Matcher::CheckOrImm: OS << "OPC_CheckOrImm"; break;
case Matcher::CheckFoldableChainNode:
OS << "OPC_CheckFoldableChainNode"; break;
case Matcher::EmitInteger: OS << "OPC_EmitInteger"; break;
case Matcher::EmitStringInteger: OS << "OPC_EmitStringInteger"; break;
case Matcher::EmitRegister: OS << "OPC_EmitRegister"; break;
case Matcher::EmitConvertToTarget: OS << "OPC_EmitConvertToTarget"; break;
case Matcher::EmitMergeInputChains: OS << "OPC_EmitMergeInputChains"; break;
case Matcher::EmitCopyToReg: OS << "OPC_EmitCopyToReg"; break;
case Matcher::EmitNode: OS << "OPC_EmitNode"; break;
case Matcher::MorphNodeTo: OS << "OPC_MorphNodeTo"; break;
case Matcher::EmitNodeXForm: OS << "OPC_EmitNodeXForm"; break;
case Matcher::MarkGlueResults: OS << "OPC_MarkGlueResults"; break;
case Matcher::CompleteMatch: OS << "OPC_CompleteMatch"; break;
}
OS.PadToColumn(40) << " = " << OpcodeFreq[i] << '\n';
}
OS << '\n';
}
开发者ID:AnachroNia,项目名称:llvm,代码行数:55,代码来源:DAGISelMatcherEmitter.cpp
示例6: LLVMTargetMachineEmit
static LLVMBool LLVMTargetMachineEmit(LLVMTargetMachineRef T, LLVMModuleRef M,
formatted_raw_ostream &OS, LLVMCodeGenFileType codegen, char **ErrorMessage) {
TargetMachine* TM = unwrap(T);
Module* Mod = unwrap(M);
PassManager pass;
std::string error;
const DataLayout *td = TM->getSubtargetImpl()->getDataLayout();
if (!td) {
error = "No DataLayout in TargetMachine";
*ErrorMessage = strdup(error.c_str());
return true;
}
Mod->setDataLayout(td);
pass.add(new DataLayoutPass());
TargetMachine::CodeGenFileType ft;
switch (codegen) {
case LLVMAssemblyFile:
ft = TargetMachine::CGFT_AssemblyFile;
break;
default:
ft = TargetMachine::CGFT_ObjectFile;
break;
}
if (TM->addPassesToEmitFile(pass, OS, ft)) {
error = "TargetMachine can't emit a file of this type";
*ErrorMessage = strdup(error.c_str());
return true;
}
pass.run(*Mod);
OS.flush();
return false;
}
开发者ID:Fairly,项目名称:opencor,代码行数:39,代码来源:TargetMachineC.cpp
示例7: EmitMatcher
/// EmitMatcher - Emit bytes for the specified matcher and return
/// the number of bytes emitted.
unsigned MatcherTableEmitter::
EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx,
formatted_raw_ostream &OS) {
OS.PadToColumn(Indent*2);
switch (N->getKind()) {
case Matcher::Scope: {
const ScopeMatcher *SM = cast<ScopeMatcher>(N);
assert(SM->getNext() == nullptr && "Shouldn't have next after scope");
unsigned StartIdx = CurrentIdx;
// Emit all of the children.
for (unsigned i = 0, e = SM->getNumChildren(); i != e; ++i) {
if (i == 0) {
OS << "OPC_Scope, ";
++CurrentIdx;
} else {
if (!OmitComments) {
OS << "/*" << CurrentIdx << "*/";
OS.PadToColumn(Indent*2) << "/*Scope*/ ";
} else
OS.PadToColumn(Indent*2);
}
// We need to encode the child and the offset of the failure code before
// emitting either of them. Handle this by buffering the output into a
// string while we get the size. Unfortunately, the offset of the
// children depends on the VBR size of the child, so for large children we
// have to iterate a bit.
SmallString<128> TmpBuf;
unsigned ChildSize = 0;
unsigned VBRSize = 0;
do {
VBRSize = GetVBRSize(ChildSize);
TmpBuf.clear();
raw_svector_ostream OS(TmpBuf);
formatted_raw_ostream FOS(OS);
ChildSize = EmitMatcherList(SM->getChild(i), Indent+1,
CurrentIdx+VBRSize, FOS);
} while (GetVBRSize(ChildSize) != VBRSize);
assert(ChildSize != 0 && "Should not have a zero-sized child!");
CurrentIdx += EmitVBRValue(ChildSize, OS);
if (!OmitComments) {
OS << "/*->" << CurrentIdx+ChildSize << "*/";
if (i == 0)
OS.PadToColumn(CommentIndent) << "// " << SM->getNumChildren()
<< " children in Scope";
}
OS << '\n' << TmpBuf;
CurrentIdx += ChildSize;
}
// Emit a zero as a sentinel indicating end of 'Scope'.
if (!OmitComments)
OS << "/*" << CurrentIdx << "*/";
OS.PadToColumn(Indent*2) << "0, ";
if (!OmitComments)
OS << "/*End of Scope*/";
OS << '\n';
return CurrentIdx - StartIdx + 1;
}
case Matcher::RecordNode:
OS << "OPC_RecordNode,";
if (!OmitComments)
OS.PadToColumn(CommentIndent) << "// #"
<< cast<RecordMatcher>(N)->getResultNo() << " = "
<< cast<RecordMatcher>(N)->getWhatFor();
OS << '\n';
return 1;
case Matcher::RecordChild:
OS << "OPC_RecordChild" << cast<RecordChildMatcher>(N)->getChildNo()
<< ',';
if (!OmitComments)
OS.PadToColumn(CommentIndent) << "// #"
<< cast<RecordChildMatcher>(N)->getResultNo() << " = "
<< cast<RecordChildMatcher>(N)->getWhatFor();
OS << '\n';
return 1;
case Matcher::RecordMemRef:
OS << "OPC_RecordMemRef,\n";
return 1;
case Matcher::CaptureGlueInput:
OS << "OPC_CaptureGlueInput,\n";
return 1;
case Matcher::MoveChild:
OS << "OPC_MoveChild, " << cast<MoveChildMatcher>(N)->getChildNo() << ",\n";
return 2;
//.........这里部分代码省略.........
开发者ID:AnachroNia,项目名称:llvm,代码行数:101,代码来源:DAGISelMatcherEmitter.cpp
示例8: printInfoComment
void DCAnnotationWriter::printInfoComment(const Value &V,
formatted_raw_ostream &OS) {
if (!isa<Instruction>(&V))
return;
const SmallVectorImpl<DCTranslatedInst::ValueInfo> *Infos = 0;
DTIT.getInstsForValue(V, Infos);
if (Infos == 0)
return;
for (int vii = 0, vie = Infos->size(); vii != vie; ++vii) {
if (vii)
OS << "\n";
const MCDecodedInst *MCDI = (*Infos)[vii].DecodedInst;
uint64_t Addr = MCDI->Address;
bool printMI = false;
const DCTranslatedInst::ValueInfo &VI = (*Infos)[vii];
OS.PadToColumn(48) << " ; ";
switch (VI.OpKind) {
default:
llvm_unreachable("Unknown translated operand type!");
case DCTranslatedInst::ValueInfo::ImpUseKind: {
OS << "imp-use ";
OS << MRI.getName(VI.RegNo);
break;
}
case DCTranslatedInst::ValueInfo::ImpDefKind: {
OS << "imp-def ";
OS << MRI.getName(VI.RegNo);
break;
}
case DCTranslatedInst::ValueInfo::RegUseKind: {
OS << " use ";
printMI = true;
break;
}
case DCTranslatedInst::ValueInfo::RegDefKind: {
OS << " def ";
printMI = true;
break;
}
case DCTranslatedInst::ValueInfo::ImmOpKind: {
OS << " imm ";
printMI = true;
break;
}
case DCTranslatedInst::ValueInfo::CustomOpKind: {
OS << " op-use ";
if (MCDI)
IP.printMachineOperand(&MCDI->Inst, VI.CustomOpType,VI.MIOperandNo,OS);
break;
}
}
if (printMI) {
if (MCDI) {
const MCOperand &MO = MCDI->Inst.getOperand(VI.MIOperandNo);
if (MO.isReg())
OS << MRI.getName(MO.getReg());
else if (MO.isImm())
OS << MO.getImm();
}
OS.PadToColumn(72);
OS << " MO#" << VI.MIOperandNo;
}
OS.PadToColumn(79);
OS << " @";
OS.write_hex(Addr);
if (MCDI)
OS << ": ";
IP.printInst(&MCDI->Inst, OS.PadToColumn(90), "");
}
}
开发者ID:AmesianX,项目名称:dagger,代码行数:78,代码来源:DCAnnotationWriter.cpp
示例9: expandPredicate
void PredicateExpander::expandPredicate(formatted_raw_ostream &OS,
const Record *Rec) {
OS.flush();
unsigned ColNum = getIndentLevel() * 2;
if (OS.getColumn() < ColNum)
OS.PadToColumn(ColNum);
if (Rec->isSubClassOf("MCTrue")) {
if (shouldNegate())
return expandFalse(OS);
return expandTrue(OS);
}
if (Rec->isSubClassOf("MCFalse")) {
if (shouldNegate())
return expandTrue(OS);
return expandFalse(OS);
}
if (Rec->isSubClassOf("CheckNot")) {
flipNegatePredicate();
expandPredicate(OS, Rec->getValueAsDef("Pred"));
flipNegatePredicate();
return;
}
if (Rec->isSubClassOf("CheckIsRegOperand"))
return expandCheckIsRegOperand(OS, Rec->getValueAsInt("OpIndex"));
if (Rec->isSubClassOf("CheckIsImmOperand"))
return expandCheckIsImmOperand(OS, Rec->getValueAsInt("OpIndex"));
if (Rec->isSubClassOf("CheckRegOperand"))
return expandCheckRegOperand(OS, Rec->getValueAsInt("OpIndex"),
Rec->getValueAsDef("Reg"));
if (Rec->isSubClassOf("CheckInvalidRegOperand"))
return expandCheckInvalidRegOperand(OS, Rec->getValueAsInt("OpIndex"));
if (Rec->isSubClassOf("CheckImmOperand"))
return expandCheckImmOperand(OS, Rec->getValueAsInt("OpIndex"),
Rec->getValueAsInt("ImmVal"));
if (Rec->isSubClassOf("CheckImmOperand_s"))
return expandCheckImmOperand(OS, Rec->getValueAsInt("OpIndex"),
Rec->getValueAsString("ImmVal"));
if (Rec->isSubClassOf("CheckSameRegOperand"))
return expandCheckSameRegOperand(OS, Rec->getValueAsInt("FirstIndex"),
Rec->getValueAsInt("SecondIndex"));
if (Rec->isSubClassOf("CheckNumOperands"))
return expandCheckNumOperands(OS, Rec->getValueAsInt("NumOps"));
if (Rec->isSubClassOf("CheckPseudo"))
return expandCheckPseudo(OS, Rec->getValueAsListOfDefs("ValidOpcodes"));
if (Rec->isSubClassOf("CheckOpcode"))
return expandCheckOpcode(OS, Rec->getValueAsListOfDefs("ValidOpcodes"));
if (Rec->isSubClassOf("CheckAll"))
return expandPredicateSequence(OS, Rec->getValueAsListOfDefs("Predicates"),
/* AllOf */ true);
if (Rec->isSubClassOf("CheckAny"))
return expandPredicateSequence(OS, Rec->getValueAsListOfDefs("Predicates"),
/* AllOf */ false);
if (Rec->isSubClassOf("CheckFunctionPredicate"))
return expandCheckFunctionPredicate(
OS, Rec->getValueAsString("MCInstFnName"),
Rec->getValueAsString("MachineInstrFnName"));
if (Rec->isSubClassOf("CheckNonPortable"))
return expandCheckNonPortable(OS, Rec->getValueAsString("CodeBlock"));
if (Rec->isSubClassOf("TIIPredicate"))
return expandTIIFunctionCall(OS, Rec->getValueAsString("TargetName"),
Rec->getValueAsString("FunctionName"));
llvm_unreachable("No known rules to expand this MCInstPredicate");
}
开发者ID:bkaradzic,项目名称:SwiftShader,代码行数:82,代码来源:PredicateExpander.cpp
示例10: generateAssemblyCode
/// Optimize merged modules using various IPO passes
bool LTOCodeGenerator::generateAssemblyCode(formatted_raw_ostream& out,
std::string& errMsg)
{
if ( this->determineTarget(errMsg) )
return true;
// mark which symbols can not be internalized
this->applyScopeRestrictions();
Module* mergedModule = _linker.getModule();
// If target supports exception handling then enable it now.
switch (_target->getTargetAsmInfo()->getExceptionHandlingType()) {
case ExceptionHandling::Dwarf:
llvm::DwarfExceptionHandling = true;
break;
case ExceptionHandling::SjLj:
llvm::SjLjExceptionHandling = true;
break;
case ExceptionHandling::None:
break;
default:
assert (0 && "Unknown exception handling model!");
}
// if options were requested, set them
if ( !_codegenOptions.empty() )
cl::ParseCommandLineOptions(_codegenOptions.size(),
(char**)&_codegenOptions[0]);
// Instantiate the pass manager to organize the passes.
PassManager passes;
// Start off with a verification pass.
passes.add(createVerifierPass());
// Add an appropriate TargetData instance for this module...
passes.add(new TargetData(*_target->getTargetData()));
createStandardLTOPasses(&passes, /*Internalize=*/ false, !DisableInline,
/*VerifyEach=*/ false);
// Make sure everything is still good.
passes.add(createVerifierPass());
FunctionPassManager* codeGenPasses =
new FunctionPassManager(new ExistingModuleProvider(mergedModule));
codeGenPasses->add(new TargetData(*_target->getTargetData()));
ObjectCodeEmitter* oce = NULL;
switch (_target->addPassesToEmitFile(*codeGenPasses, out,
TargetMachine::AssemblyFile,
CodeGenOpt::Aggressive)) {
case FileModel::MachOFile:
oce = AddMachOWriter(*codeGenPasses, out, *_target);
break;
case FileModel::ElfFile:
oce = AddELFWriter(*codeGenPasses, out, *_target);
break;
case FileModel::AsmFile:
break;
case FileModel::Error:
case FileModel::None:
errMsg = "target file type not supported";
return true;
}
if (_target->addPassesToEmitFileFinish(*codeGenPasses, oce,
CodeGenOpt::Aggressive)) {
errMsg = "target does not support generation of this file type";
return true;
}
// Run our queue of passes all at once now, efficiently.
passes.run(*mergedModule);
// Run the code generator, and write assembly file
codeGenPasses->doInitialization();
for (Module::iterator
it = mergedModule->begin(), e = mergedModule->end(); it != e; ++it)
if (!it->isDeclaration())
codeGenPasses->run(*it);
codeGenPasses->doFinalization();
out.flush();
return false; // success
}
开发者ID:idkwim,项目名称:symbolic-execution,代码行数:93,代码来源:LTOCodeGenerator.cpp
注:本文中的formatted_raw_ostream类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论