本文整理汇总了C++中ValueSymbolTable类的典型用法代码示例。如果您正苦于以下问题:C++ ValueSymbolTable类的具体用法?C++ ValueSymbolTable怎么用?C++ ValueSymbolTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ValueSymbolTable类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: value
/// takeName - transfer the name from V to this value, setting V's name to
/// empty. It is an error to call V->takeName(V).
void Value::takeName(Value *V) {
ValueSymbolTable *ST = 0;
// If this value has a name, drop it.
if (hasName()) {
// Get the symtab this is in.
if (getSymTab(this, ST)) {
// We can't set a name on this value, but we need to clear V's name if
// it has one.
if (V->hasName()) V->setName("");
return; // Cannot set a name on this value (e.g. constant).
}
// Remove old name.
if (ST)
ST->removeValueName(Name);
Name->Destroy();
Name = 0;
}
// Now we know that this has no name.
// If V has no name either, we're done.
if (!V->hasName()) return;
// Get this's symtab if we didn't before.
if (!ST) {
if (getSymTab(this, ST)) {
// Clear V's name.
V->setName("");
return; // Cannot set a name on this value (e.g. constant).
}
}
// Get V's ST, this should always succed, because V has a name.
ValueSymbolTable *VST;
bool Failure = getSymTab(V, VST);
assert(!Failure && "V has a name, so it should have a ST!"); Failure=Failure;
// If these values are both in the same symtab, we can do this very fast.
// This works even if both values have no symtab yet.
if (ST == VST) {
// Take the name!
Name = V->Name;
V->Name = 0;
Name->setValue(this);
return;
}
// Otherwise, things are slightly more complex. Remove V's name from VST and
// then reinsert it into ST.
if (VST)
VST->removeValueName(V->Name);
Name = V->Name;
V->Name = 0;
Name->setValue(this);
if (ST)
ST->reinsertValue(this);
}
开发者ID:dmlap,项目名称:llvm-js-backend,代码行数:62,代码来源:Value.cpp
示例2: assert
void Value::setName(const Twine &NewName) {
// Fast path for common IRBuilder case of setName("") when there is no name.
if (NewName.isTriviallyEmpty() && !hasName())
return;
SmallString<256> NameData;
NewName.toVector(NameData);
const char *NameStr = NameData.data();
unsigned NameLen = NameData.size();
// Name isn't changing?
if (getName() == StringRef(NameStr, NameLen))
return;
assert(getType() != Type::getVoidTy(getContext()) &&
"Cannot assign a name to void values!");
// Get the symbol table to update for this object.
ValueSymbolTable *ST;
if (getSymTab(this, ST))
return; // Cannot set a name on this value (e.g. constant).
if (!ST) { // No symbol table to update? Just do the change.
if (NameLen == 0) {
// Free the name for this value.
Name->Destroy();
Name = 0;
return;
}
if (Name)
Name->Destroy();
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
// Create the new name.
Name = ValueName::Create(NameStr, NameStr+NameLen);
Name->setValue(this);
return;
}
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
if (hasName()) {
// Remove old name.
ST->removeValueName(Name);
Name->Destroy();
Name = 0;
if (NameLen == 0)
return;
}
// Name is changing to something new.
Name = ST->createValueName(StringRef(NameStr, NameLen), this);
}
开发者ID:aaasz,项目名称:SHP,代码行数:58,代码来源:Value.cpp
示例3: WriteValueSymbolTable
// Emit names for globals/functions etc.
static void WriteValueSymbolTable(const ValueSymbolTable &VST,
const NaClValueEnumerator &VE,
NaClBitstreamWriter &Stream) {
if (VST.empty()) return;
Stream.EnterSubblock(naclbitc::VALUE_SYMTAB_BLOCK_ID);
// FIXME: Set up the abbrev, we know how many values there are!
// FIXME: We know if the type names can use 7-bit ascii.
SmallVector<unsigned, 64> NameVals;
for (ValueSymbolTable::const_iterator SI = VST.begin(), SE = VST.end();
SI != SE; ++SI) {
if (VE.IsElidedCast(SI->getValue())) continue;
const ValueName &Name = *SI;
// Figure out the encoding to use for the name.
bool is7Bit = true;
bool isChar6 = true;
for (const char *C = Name.getKeyData(), *E = C+Name.getKeyLength();
C != E; ++C) {
if (isChar6)
isChar6 = NaClBitCodeAbbrevOp::isChar6(*C);
if ((unsigned char)*C & 128) {
is7Bit = false;
break; // don't bother scanning the rest.
}
}
unsigned AbbrevToUse = VST_ENTRY_8_ABBREV;
// VST_ENTRY: [valueid, namechar x N]
// VST_BBENTRY: [bbid, namechar x N]
unsigned Code;
if (isa<BasicBlock>(SI->getValue())) {
Code = naclbitc::VST_CODE_BBENTRY;
if (isChar6)
AbbrevToUse = VST_BBENTRY_6_ABBREV;
} else {
Code = naclbitc::VST_CODE_ENTRY;
if (isChar6)
AbbrevToUse = VST_ENTRY_6_ABBREV;
else if (is7Bit)
AbbrevToUse = VST_ENTRY_7_ABBREV;
}
NameVals.push_back(VE.getValueID(SI->getValue()));
for (const char *P = Name.getKeyData(),
*E = Name.getKeyData()+Name.getKeyLength(); P != E; ++P)
NameVals.push_back((unsigned char)*P);
// Emit the finished record.
Stream.EmitRecord(Code, NameVals, AbbrevToUse);
NameVals.clear();
}
Stream.ExitBlock();
}
开发者ID:Maher4Ever,项目名称:emscripten-fastcomp,代码行数:58,代码来源:NaClBitcodeWriter.cpp
示例4: assert
void Value::setName(const Twine &NewName) {
assert(SubclassID != MDStringVal &&
"Cannot set the name of MDString with this method!");
// Fast path for common IRBuilder case of setName("") when there is no name.
if (NewName.isTriviallyEmpty() && !hasName())
return;
SmallString<256> NameData;
StringRef NameRef = NewName.toStringRef(NameData);
// Name isn't changing?
if (getName() == NameRef)
return;
assert(!getType()->isVoidTy() && "Cannot assign a name to void values!");
// Get the symbol table to update for this object.
ValueSymbolTable *ST;
if (getSymTab(this, ST))
return; // Cannot set a name on this value (e.g. constant).
if (!ST) { // No symbol table to update? Just do the change.
if (NameRef.empty()) {
// Free the name for this value.
Name->Destroy();
Name = 0;
return;
}
if (Name)
Name->Destroy();
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
// Create the new name.
Name = ValueName::Create(NameRef.begin(), NameRef.end());
Name->setValue(this);
return;
}
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
if (hasName()) {
// Remove old name.
ST->removeValueName(Name);
Name->Destroy();
Name = 0;
if (NameRef.empty())
return;
}
// Name is changing to something new.
Name = ST->createValueName(NameRef, this);
}
开发者ID:Abocer,项目名称:android-4.2_r1,代码行数:57,代码来源:Value.cpp
示例5: assert
void Value::setNameImpl(const Twine &NewName) {
// Fast-path: LLVMContext can be set to strip out non-GlobalValue names
if (getContext().shouldDiscardValueNames() && !isa<GlobalValue>(this))
return;
// Fast path for common IRBuilder case of setName("") when there is no name.
if (NewName.isTriviallyEmpty() && !hasName())
return;
SmallString<256> NameData;
StringRef NameRef = NewName.toStringRef(NameData);
assert(NameRef.find_first_of(0) == StringRef::npos &&
"Null bytes are not allowed in names");
// Name isn't changing?
if (getName() == NameRef)
return;
assert(!getType()->isVoidTy() && "Cannot assign a name to void values!");
// Get the symbol table to update for this object.
ValueSymbolTable *ST;
if (getSymTab(this, ST))
return; // Cannot set a name on this value (e.g. constant).
if (!ST) { // No symbol table to update? Just do the change.
if (NameRef.empty()) {
// Free the name for this value.
destroyValueName();
return;
}
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
destroyValueName();
// Create the new name.
setValueName(ValueName::Create(NameRef));
getValueName()->setValue(this);
return;
}
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
if (hasName()) {
// Remove old name.
ST->removeValueName(getValueName());
destroyValueName();
if (NameRef.empty())
return;
}
// Name is changing to something new.
setValueName(ST->createValueName(NameRef, this));
}
开发者ID:bugsnag,项目名称:llvm,代码行数:56,代码来源:Value.cpp
示例6: StripSymtab
// Strip the symbol table of its names.
//
static void StripSymtab(ValueSymbolTable &ST, bool PreserveDbgInfo) {
for (ValueSymbolTable::iterator VI = ST.begin(), VE = ST.end(); VI != VE; ) {
Value *V = VI->getValue();
++VI;
if (!isa<GlobalValue>(V) || cast<GlobalValue>(V)->hasLocalLinkage()) {
if (!PreserveDbgInfo || !V->getName().startswith("llvm.dbg"))
// Set name to "", removing from symbol table!
V->setName("");
}
}
}
开发者ID:jyasskin,项目名称:llvm-mirror,代码行数:13,代码来源:StripSymbols.cpp
示例7: assert
void Value::setName(const char *NameStr, unsigned NameLen) {
if (NameLen == 0 && !hasName()) return;
assert(getType() != Type::VoidTy && "Cannot assign a name to void values!");
// Get the symbol table to update for this object.
ValueSymbolTable *ST;
if (getSymTab(this, ST))
return; // Cannot set a name on this value (e.g. constant).
if (!ST) { // No symbol table to update? Just do the change.
if (NameLen == 0) {
// Free the name for this value.
Name->Destroy();
Name = 0;
return;
}
if (Name) {
// Name isn't changing?
if (NameLen == Name->getKeyLength() &&
!memcmp(Name->getKeyData(), NameStr, NameLen))
return;
Name->Destroy();
}
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
// Create the new name.
Name = ValueName::Create(NameStr, NameStr+NameLen);
Name->setValue(this);
return;
}
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
if (hasName()) {
// Name isn't changing?
if (NameLen == Name->getKeyLength() &&
!memcmp(Name->getKeyData(), NameStr, NameLen))
return;
// Remove old name.
ST->removeValueName(Name);
Name->Destroy();
Name = 0;
if (NameLen == 0)
return;
}
// Name is changing to something new.
Name = ST->createValueName(NameStr, NameLen, this);
}
开发者ID:blickly,项目名称:llvm-clang-PRETC,代码行数:54,代码来源:Value.cpp
示例8: EnumerateValueSymbolTable
/// EnumerateValueSymbolTable - Insert all of the values in the specified symbol
/// table into the values table.
void ValueEnumerator::EnumerateValueSymbolTable(const ValueSymbolTable &VST) {
for (ValueSymbolTable::const_iterator VI = VST.begin(), VE = VST.end();
VI != VE; ++VI)
EnumerateValue(VI->getValue());
}
开发者ID:abyadtherock,项目名称:emscripten-fastcomp,代码行数:7,代码来源:ValueEnumerator.cpp
示例9: assert
void Value::setName(const Twine &NewName) {
assert(SubclassID != MDStringVal &&
"Cannot set the name of MDString with this method!");
// Fast path for common IRBuilder case of setName("") when there is no name.
if (NewName.isTriviallyEmpty() && !hasName())
return;
SmallString<256> NameData;
StringRef NameRef = NewName.toStringRef(NameData);
assert(NameRef.find_first_of(0) == StringRef::npos &&
"Null bytes are not allowed in names");
// Name isn't changing?
if (getName() == NameRef)
return;
assert(!getType()->isVoidTy() && "Cannot assign a name to void values!");
// Get the symbol table to update for this object.
ValueSymbolTable *ST;
if (getSymTab(this, ST))
return; // Cannot set a name on this value (e.g. constant).
if (Function *F = dyn_cast<Function>(this))
getContext().pImpl->IntrinsicIDCache.erase(F);
if (!ST) { // No symbol table to update? Just do the change.
if (NameRef.empty()) {
// Free the name for this value.
Name->Destroy();
Name = nullptr;
return;
}
if (Name)
Name->Destroy();
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
// Create the new name.
Name = ValueName::Create(NameRef);
Name->setValue(this);
return;
}
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
if (hasName()) {
// Remove old name.
ST->removeValueName(Name);
Name->Destroy();
Name = nullptr;
if (NameRef.empty())
return;
}
// Name is changing to something new.
Name = ST->createValueName(NameRef, this);
}
开发者ID:MrFredMiles,项目名称:llvm,代码行数:62,代码来源:Value.cpp
注:本文中的ValueSymbolTable类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论