[llvm-commits] CVS: llvm-gcc/gcc/llvm-expand.c llvm-representation.c
Chris Lattner
lattner at cs.uiuc.edu
Sat Sep 24 01:34:07 PDT 2005
Changes in directory llvm-gcc/gcc:
llvm-expand.c updated: 1.113 -> 1.114
llvm-representation.c updated: 1.19 -> 1.20
---
Log message:
Patch to fix PR630: http://llvm.cs.uiuc.edu/PR630 .
For asm labels, emit a prefix (char)1 byte to mark the asm label as not needing
a user_label_prefix instead of a '*' like we used to.
Change llvm-representation to not skip the '*' when emitting a label. Also
teach it to correctly emit labels that have escape codes in it.
Finally, for asm labels, if they start with the user_label_prefix, strip it
off and make it a normal label.
---
Diffs of the changes: (+39 -9)
llvm-expand.c | 15 ++++++++++++---
llvm-representation.c | 33 +++++++++++++++++++++++++++------
2 files changed, 39 insertions(+), 9 deletions(-)
Index: llvm-gcc/gcc/llvm-expand.c
diff -u llvm-gcc/gcc/llvm-expand.c:1.113 llvm-gcc/gcc/llvm-expand.c:1.114
--- llvm-gcc/gcc/llvm-expand.c:1.113 Wed Sep 21 01:54:29 2005
+++ llvm-gcc/gcc/llvm-expand.c Sat Sep 24 03:33:56 2005
@@ -7556,10 +7556,19 @@
reg_number = decode_reg_name (asmspec);
if (reg_number == -2) {
/* ASMSPEC is given, and not the name of a register. Mark the
- name with a star so assemble_name won't munge it. */
+ name with a leading 1 so assemble_name won't munge it. */
char *starred = alloca (strlen (asmspec) + 2);
- starred[0] = '*';
- strcpy (starred + 1, asmspec);
+
+ /* If this thing just starts with user_label_prefix, there is no need for it
+ * to be an asm string.
+ */
+ if (strncmp(user_label_prefix, asmspec, strlen(user_label_prefix)) == 0) {
+ strcpy(starred, asmspec+strlen(user_label_prefix));
+ } else {
+ /* real asm label */
+ starred[0] = 1;
+ strcpy (starred + 1, asmspec);
+ }
SET_DECL_ASSEMBLER_NAME (decl, get_identifier (starred));
}
Index: llvm-gcc/gcc/llvm-representation.c
diff -u llvm-gcc/gcc/llvm-representation.c:1.19 llvm-gcc/gcc/llvm-representation.c:1.20
--- llvm-gcc/gcc/llvm-representation.c:1.19 Thu Jul 7 12:32:46 2005
+++ llvm-gcc/gcc/llvm-representation.c Sat Sep 24 03:33:56 2005
@@ -191,7 +191,6 @@
Val->VTy = VT;
GlobalVal = llvm_value_is_global(Val) ? Val : 0;
Val->Ty = (struct llvm_type*) Type;
- if (Name[0] == '*') ++Name;
Val->Name = Name[0] ? IdentifierTableGetName(Name, GlobalVal) : xstrdup(Name);
}
@@ -211,6 +210,23 @@
fprintf(stderr, "\n");
}
+/* PrintIdentifier - Print the specified identifier to the specified file. If
+ * the identifier needs escaping, use "foo" style, otherwise use %foo style.
+ */
+static void PrintIdentifier(const char *ID, FILE *F) {
+ int isSafe = !isdigit(ID[0]), i;
+ for (i = 0; ID[i]; ++i)
+ if (!isalnum(ID[i]) &&
+ ID[i] != '$' && ID[i] != '.' && ID[i] != '_' && ID[i] != '-') {
+ isSafe = 0;
+ break;
+ }
+ if (isSafe)
+ fprintf(F, "%%%s", ID);
+ else
+ fprintf(F, "\"%s\"", ID);
+}
+
/* llvm_value_print_operand - Print the specified value formatted as
an operand. If PrintType is true, the type is printed as a
prefix. */
@@ -250,7 +266,7 @@
llvm_type_print(G2V(GV)->Ty, F);
fprintf(F, ")");
} else if (V->Name[0]) {
- fprintf(F, "%%%s", V->Name);
+ PrintIdentifier(V->Name, F);
} else if (!PrintType) {
fprintf(stderr, "ERROR, didn't print ANYTHING for operand!");
abort();
@@ -664,7 +680,8 @@
/* if it has a name... print it */
if (D2V(I)->Name && D2V(I)->Name[0]) {
- fprintf(F, "%%%s = ", D2V(I)->Name);
+ PrintIdentifier(D2V(I)->Name, F);
+ fprintf(F, " = ");
}
if ((I->Opcode == O_Load || I->Opcode == O_Store) &&
@@ -880,7 +897,9 @@
}
llvm_type_print(Ty->Elements[0], F);
- fprintf(F, " %%%s(", G2V(Fn)->Name);
+ fprintf(F, " ");
+ PrintIdentifier(G2V(Fn)->Name, F);
+ fprintf(F, "(");
/* Print out all of the arguments */
if (!isPrototype) {
@@ -947,8 +966,10 @@
return;
}
- if (G2V(G)->Name)
- fprintf(F, "%%%s = ", G2V(G)->Name);
+ if (G2V(G)->Name) {
+ PrintIdentifier(G2V(G)->Name, F);
+ fprintf(F, " = ");
+ }
if (G->Init == 0)
fprintf(F, "external ");
More information about the llvm-commits
mailing list