Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: src/IceCfg.h

Issue 1838753002: Subzero: Remove IceString. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceBrowserCompileServer.cpp ('k') | src/IceCfg.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceCfg.h
diff --git a/src/IceCfg.h b/src/IceCfg.h
index 95d79bcba2e554b7453a1412b63e6cb5e9ea2b2e..f6f330909e064a7c6837871fbd0c0d2b624bca27 100644
--- a/src/IceCfg.h
+++ b/src/IceCfg.h
@@ -20,6 +20,7 @@
#include "IceClFlags.h"
#include "IceDefs.h"
#include "IceGlobalContext.h"
+#include "IceStringPool.h"
#include "IceTypes.h"
namespace Ice {
@@ -53,9 +54,9 @@ public:
/// \name Manage the name and return type of the function being translated.
/// @{
- void setFunctionName(const IceString &Name) { FunctionName = Name; }
- const IceString &getFunctionName() const { return FunctionName; }
- IceString getFunctionNameAndSize() const;
+ void setFunctionName(GlobalString Name) { FunctionName = Name; }
+ GlobalString getFunctionName() const { return FunctionName; }
+ std::string getFunctionNameAndSize() const;
void setReturnType(Type Ty) { ReturnType = Ty; }
Type getReturnType() const { return ReturnType; }
/// @}
@@ -73,9 +74,9 @@ public:
/// missing, instead of an assertion failure, setError() should be called and
/// the error should be propagated back up. This way, we can gracefully fail
/// to translate and let a fallback translator handle the function.
- void setError(const IceString &Message);
+ void setError(const std::string &Message);
bool hasError() const { return HasError; }
- IceString getError() const { return ErrorMessage; }
+ std::string getError() const { return ErrorMessage; }
/// @}
/// \name Manage nodes (a.k.a. basic blocks, CfgNodes).
@@ -93,20 +94,10 @@ public:
void swapNodes(NodeList &NewNodes);
/// @}
- using IdentifierIndexType = int32_t;
- /// Adds a name to the list and returns its index, suitable for the argument
- /// to getIdentifierName(). No checking for duplicates is done. This is
- /// generally used for node names and variable names to avoid embedding a
- /// std::string inside an arena-allocated object.
- IdentifierIndexType addIdentifierName(const IceString &Name) {
- IdentifierIndexType Index = IdentifierNames.size();
- IdentifierNames.push_back(Name);
- return Index;
- }
- const IceString &getIdentifierName(IdentifierIndexType Index) const {
- return IdentifierNames[Index];
- }
- enum { IdentifierIndexInvalid = -1 };
+ /// String pool for CfgNode::Name values.
+ StringPool *getNodeStrings() const { return NodeStrings.get(); }
+ /// String pool for Variable::Name values.
+ StringPool *getVarStrings() const { return VarStrings.get(); }
/// \name Manage instruction numbering.
/// @{
@@ -241,7 +232,7 @@ public:
void emit();
void emitIAS();
- static void emitTextHeader(const IceString &Name, GlobalContext *Ctx,
+ static void emitTextHeader(GlobalString Name, GlobalContext *Ctx,
const Assembler *Asm);
void dump(const char *Message = "");
@@ -277,9 +268,9 @@ private:
/// code needs to be defined.
void profileBlocks();
- void createNodeNameDeclaration(const IceString &NodeAsmName);
+ void createNodeNameDeclaration(const std::string &NodeAsmName);
void
- createBlockProfilingInfoDeclaration(const IceString &NodeAsmName,
+ createBlockProfilingInfoDeclaration(const std::string &NodeAsmName,
VariableDeclaration *NodeNameDeclaration);
/// Delete registered jump table placeholder instructions. This should only be
@@ -302,20 +293,23 @@ private:
uint32_t SequenceNumber; /// output order for emission
uint32_t ConstantBlindingCookie = 0; /// cookie for constant blinding
VerboseMask VMask;
- IceString FunctionName = "";
+ GlobalString FunctionName;
Type ReturnType = IceType_void;
bool IsInternalLinkage = false;
bool HasError = false;
bool FocusedTiming = false;
- IceString ErrorMessage = "";
+ std::string ErrorMessage = "";
CfgNode *Entry = nullptr; /// entry basic block
NodeList Nodes; /// linearized node list; Entry should be first
- std::vector<IceString> IdentifierNames;
InstNumberT NextInstNumber;
VarList Variables;
VarList Args; /// subset of Variables, in argument order
VarList ImplicitArgs; /// subset of Variables
std::unique_ptr<ArenaAllocator> Allocator;
+ // Separate string pools for CfgNode and Variable names, due to a combination
+ // of the uniqueness requirement, and assumptions in lit tests.
+ std::unique_ptr<StringPool> NodeStrings;
+ std::unique_ptr<StringPool> VarStrings;
std::unique_ptr<Liveness> Live;
std::unique_ptr<TargetLowering> Target;
std::unique_ptr<VariablesMetadata> VMetadata;
@@ -336,6 +330,22 @@ public:
template <> Variable *Cfg::makeVariable<Variable>(Type Ty);
+struct NodeStringPoolTraits {
+ using OwnerType = Cfg;
+ static StringPool *getStrings(const OwnerType *PoolOwner) {
+ return PoolOwner->getNodeStrings();
+ }
+};
+using NodeString = StringID<NodeStringPoolTraits>;
+
+struct VariableStringPoolTraits {
+ using OwnerType = Cfg;
+ static StringPool *getStrings(const OwnerType *PoolOwner) {
+ return PoolOwner->getVarStrings();
+ }
+};
+using VariableString = StringID<VariableStringPoolTraits>;
+
} // end of namespace Ice
#endif // SUBZERO_SRC_ICECFG_H
« no previous file with comments | « src/IceBrowserCompileServer.cpp ('k') | src/IceCfg.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698