summaryrefslogtreecommitdiffstats
path: root/opcode-gen
diff options
context:
space:
mode:
authorDan Bornstein <danfuzz@android.com>2010-11-16 13:09:45 -0800
committerDan Bornstein <danfuzz@android.com>2010-11-16 13:14:42 -0800
commit11a4a79b09a2be2bd7a7141ce112de3ad0432e53 (patch)
tree86835bda5d99552674bc82656f67243f9fb0966d /opcode-gen
parent82dbe1c22c6a1088f73f1e11e5cacbdd492ca79d (diff)
downloadandroid_dalvik-11a4a79b09a2be2bd7a7141ce112de3ad0432e53.tar.gz
android_dalvik-11a4a79b09a2be2bd7a7141ce112de3ad0432e53.tar.bz2
android_dalvik-11a4a79b09a2be2bd7a7141ce112de3ad0432e53.zip
Generate most of OpCode.h using opcode-gen.
This was the easiest bit to tackle in libdex. More to come! Change-Id: I3f79039ce98951d694d2c896ee1c7a60b417bc49
Diffstat (limited to 'opcode-gen')
-rwxr-xr-xopcode-gen/opcode-gen39
-rwxr-xr-xopcode-gen/regen-all4
2 files changed, 40 insertions, 3 deletions
diff --git a/opcode-gen/opcode-gen b/opcode-gen/opcode-gen
index f57026815..7b2c36307 100755
--- a/opcode-gen/opcode-gen
+++ b/opcode-gen/opcode-gen
@@ -62,6 +62,7 @@ awk -v "bytecodeFile=$bytecodeFile" '
BEGIN {
MAX_OPCODE = 65535;
+ MAX_LIBDEX_OPCODE = 255; # TODO: Will not be true for long!
initIndexTypes();
initFlags();
if (readBytecodes()) exit 1;
@@ -137,6 +138,29 @@ consumeUntil != "" {
next;
}
+/BEGIN\(libdex-opcode-enum\)/ {
+ consumeUntil = "END(libdex-opcode-enum)";
+ print;
+
+ for (i = 0; i <= MAX_LIBDEX_OPCODE; i++) {
+ printf(" OP_%-28s = 0x%02x,\n", uppernameOrUnusedByte(i), i);
+ }
+
+ next;
+}
+
+/BEGIN\(libdex-goto-table\)/ {
+ consumeUntil = "END(libdex-goto-table)";
+ print;
+
+ for (i = 0; i <= MAX_LIBDEX_OPCODE; i++) {
+ content = sprintf(" H(OP_%s),", uppernameOrUnusedByte(i));
+ printf("%-78s\\\n", content);
+ }
+
+ next;
+}
+
{ print; }
# Read the bytecode description file.
@@ -369,6 +393,21 @@ function isUnused(idx, n) {
n = name[idx];
return (n == "") || (index(n, "unused") != 0);
}
+
+# Returns the uppercase name of the given single-byte opcode (by
+# index) or the string "UNUSED_XX" (where XX is the index in hex) if
+# the opcode is unused. The odd case for this function is 255, which
+# is the first extended (two-byte) opcode. For the purposes of this
+# function, it is considered unused. (This is meant as a stop-gap
+# measure for code that is not yet prepared to deal with extended
+# opcodes.)
+function uppernameOrUnusedByte(idx, n) {
+ n = uppername[idx];
+ if ((n == "") || (i == 255)) {
+ return toupper(sprintf("UNUSED_%02x", idx));
+ }
+ return n;
+}
' "$file" > "$tmpfile"
cp "$tmpfile" "$file"
diff --git a/opcode-gen/regen-all b/opcode-gen/regen-all
index 790bf84e8..32330e86d 100755
--- a/opcode-gen/regen-all
+++ b/opcode-gen/regen-all
@@ -37,6 +37,4 @@ cd ".."
${progdir}/opcode-gen dx/src/com/android/dx/dex/code/DalvOps.java
${progdir}/opcode-gen dx/src/com/android/dx/dex/code/Dops.java
${progdir}/opcode-gen dx/src/com/android/dx/dex/code/RopToDop.java
-
-# Coming soon!
-# ${progdir}/opcode-gen libdex/OpCode.h
+${progdir}/opcode-gen libdex/OpCode.h