mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-17 15:38:40 +00:00
Cleanups:
Mangler.cpp: Constify parameter to makeNameProper, and use const_iterator. Make Count an unsigned int, and use utostr(). Don't name parameters things that start with underscore. Mangler.h: All of the above, and also: Add Emacs mode-line. Include <set>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7301 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b198ca304b
commit
4166445b7c
@ -1,4 +1,4 @@
|
|||||||
//===-- Mangler.h - Self-contained c/asm llvm name mangler ----------------===//
|
//===-- Mangler.h - Self-contained c/asm llvm name mangler -*- C++ -*- ----===//
|
||||||
//
|
//
|
||||||
// Unified name mangler for CWriter and assembly backends.
|
// Unified name mangler for CWriter and assembly backends.
|
||||||
//
|
//
|
||||||
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
class Value;
|
class Value;
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
class Mangler {
|
class Mangler {
|
||||||
public:
|
public:
|
||||||
@ -17,7 +18,7 @@ public:
|
|||||||
///
|
///
|
||||||
std::string getValueName(const Value *V);
|
std::string getValueName(const Value *V);
|
||||||
|
|
||||||
Mangler(Module &_M);
|
Mangler(Module &M_);
|
||||||
|
|
||||||
/// makeNameProper - We don't want identifier names with ., space, or
|
/// makeNameProper - We don't want identifier names with ., space, or
|
||||||
/// - in them, so we mangle these characters into the strings "d_",
|
/// - in them, so we mangle these characters into the strings "d_",
|
||||||
@ -26,7 +27,7 @@ public:
|
|||||||
/// does this for you, so there's no point calling it on the result
|
/// does this for you, so there's no point calling it on the result
|
||||||
/// from getValueName.
|
/// from getValueName.
|
||||||
///
|
///
|
||||||
static std::string makeNameProper(std::string x);
|
static std::string makeNameProper(const std::string &x);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// This keeps track of which global values have had their names
|
/// This keeps track of which global values have had their names
|
||||||
@ -39,7 +40,7 @@ private:
|
|||||||
typedef std::map<const Value *, std::string> ValueMap;
|
typedef std::map<const Value *, std::string> ValueMap;
|
||||||
ValueMap Memo;
|
ValueMap Memo;
|
||||||
|
|
||||||
long long Count;
|
unsigned int Count;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LLVM_SUPPORT_MANGLER_H
|
#endif // LLVM_SUPPORT_MANGLER_H
|
||||||
|
@ -17,9 +17,10 @@
|
|||||||
/// - in them, so we mangle these characters into the strings "d_",
|
/// - in them, so we mangle these characters into the strings "d_",
|
||||||
/// "s_", and "D_", respectively.
|
/// "s_", and "D_", respectively.
|
||||||
///
|
///
|
||||||
std::string Mangler::makeNameProper(std::string x) {
|
std::string Mangler::makeNameProper(const std::string &x) {
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
for (std::string::iterator sI = x.begin(), sEnd = x.end(); sI != sEnd; sI++)
|
for (std::string::const_iterator sI = x.begin(), sEnd = x.end();
|
||||||
|
sI != sEnd; sI++)
|
||||||
switch (*sI) {
|
switch (*sI) {
|
||||||
case '.': tmp += "d_"; break;
|
case '.': tmp += "d_"; break;
|
||||||
case ' ': tmp += "s_"; break;
|
case ' ': tmp += "s_"; break;
|
||||||
@ -54,14 +55,14 @@ std::string Mangler::getValueName(const Value *V) {
|
|||||||
makeNameProper(V->getName());
|
makeNameProper(V->getName());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
name = "ltmp_" + itostr(Count++) + "_"
|
name = "ltmp_" + utostr(Count++) + "_"
|
||||||
+ utostr(V->getType()->getUniqueID());
|
+ utostr(V->getType()->getUniqueID());
|
||||||
}
|
}
|
||||||
Memo[V] = name;
|
Memo[V] = name;
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mangler::Mangler(Module &_M) : M(_M)
|
Mangler::Mangler(Module &M_) : M(M_)
|
||||||
{
|
{
|
||||||
// Calculate which global values have names that will collide when we throw
|
// Calculate which global values have names that will collide when we throw
|
||||||
// away type information.
|
// away type information.
|
||||||
|
@ -17,9 +17,10 @@
|
|||||||
/// - in them, so we mangle these characters into the strings "d_",
|
/// - in them, so we mangle these characters into the strings "d_",
|
||||||
/// "s_", and "D_", respectively.
|
/// "s_", and "D_", respectively.
|
||||||
///
|
///
|
||||||
std::string Mangler::makeNameProper(std::string x) {
|
std::string Mangler::makeNameProper(const std::string &x) {
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
for (std::string::iterator sI = x.begin(), sEnd = x.end(); sI != sEnd; sI++)
|
for (std::string::const_iterator sI = x.begin(), sEnd = x.end();
|
||||||
|
sI != sEnd; sI++)
|
||||||
switch (*sI) {
|
switch (*sI) {
|
||||||
case '.': tmp += "d_"; break;
|
case '.': tmp += "d_"; break;
|
||||||
case ' ': tmp += "s_"; break;
|
case ' ': tmp += "s_"; break;
|
||||||
@ -54,14 +55,14 @@ std::string Mangler::getValueName(const Value *V) {
|
|||||||
makeNameProper(V->getName());
|
makeNameProper(V->getName());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
name = "ltmp_" + itostr(Count++) + "_"
|
name = "ltmp_" + utostr(Count++) + "_"
|
||||||
+ utostr(V->getType()->getUniqueID());
|
+ utostr(V->getType()->getUniqueID());
|
||||||
}
|
}
|
||||||
Memo[V] = name;
|
Memo[V] = name;
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mangler::Mangler(Module &_M) : M(_M)
|
Mangler::Mangler(Module &M_) : M(M_)
|
||||||
{
|
{
|
||||||
// Calculate which global values have names that will collide when we throw
|
// Calculate which global values have names that will collide when we throw
|
||||||
// away type information.
|
// away type information.
|
||||||
|
@ -17,9 +17,10 @@
|
|||||||
/// - in them, so we mangle these characters into the strings "d_",
|
/// - in them, so we mangle these characters into the strings "d_",
|
||||||
/// "s_", and "D_", respectively.
|
/// "s_", and "D_", respectively.
|
||||||
///
|
///
|
||||||
std::string Mangler::makeNameProper(std::string x) {
|
std::string Mangler::makeNameProper(const std::string &x) {
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
for (std::string::iterator sI = x.begin(), sEnd = x.end(); sI != sEnd; sI++)
|
for (std::string::const_iterator sI = x.begin(), sEnd = x.end();
|
||||||
|
sI != sEnd; sI++)
|
||||||
switch (*sI) {
|
switch (*sI) {
|
||||||
case '.': tmp += "d_"; break;
|
case '.': tmp += "d_"; break;
|
||||||
case ' ': tmp += "s_"; break;
|
case ' ': tmp += "s_"; break;
|
||||||
@ -54,14 +55,14 @@ std::string Mangler::getValueName(const Value *V) {
|
|||||||
makeNameProper(V->getName());
|
makeNameProper(V->getName());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
name = "ltmp_" + itostr(Count++) + "_"
|
name = "ltmp_" + utostr(Count++) + "_"
|
||||||
+ utostr(V->getType()->getUniqueID());
|
+ utostr(V->getType()->getUniqueID());
|
||||||
}
|
}
|
||||||
Memo[V] = name;
|
Memo[V] = name;
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mangler::Mangler(Module &_M) : M(_M)
|
Mangler::Mangler(Module &M_) : M(M_)
|
||||||
{
|
{
|
||||||
// Calculate which global values have names that will collide when we throw
|
// Calculate which global values have names that will collide when we throw
|
||||||
// away type information.
|
// away type information.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user