[llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp
Alkis Evlogimenos
alkis at cs.uiuc.edu
Sat May 22 19:20:02 PDT 2004
Changes in directory llvm-java/lib/Compiler:
Compiler.cpp updated: 1.3 -> 1.4
---
Log message:
Rename utility functions for reading immediates from bytecode. Add
functions to read ints as well.
---
Diffs of the changes: (+24 -13)
Index: llvm-java/lib/Compiler/Compiler.cpp
diff -u llvm-java/lib/Compiler/Compiler.cpp:1.3 llvm-java/lib/Compiler/Compiler.cpp:1.4
--- llvm-java/lib/Compiler/Compiler.cpp:1.3 Sat May 22 18:25:22 2004
+++ llvm-java/lib/Compiler/Compiler.cpp Sat May 22 19:18:36 2004
@@ -33,20 +33,31 @@
return !isTwoSlotValue(v);
}
- inline int readByteImmediate(const uint8_t* code, unsigned& i) {
+ inline int readByteSigned(const uint8_t* code, unsigned& i) {
return code[++i];
}
- inline int readShortImmediate(const uint8_t* code, unsigned& i) {
- return (code[++i] << 8) | code[++i];
+ inline unsigned readByteUnsigned(const uint8_t* code, unsigned& i) {
+ return code[++i];
}
- inline unsigned readByteIndex(const uint8_t* code, unsigned& i) {
- return code[++i];
+ inline int readShortSigned(const uint8_t* code, unsigned& i) {
+ return (readByteSigned(code, i) << 8) | readByteUnsigned(code, i);
+ }
+
+ inline unsigned readShortUnsigned(const uint8_t* code, unsigned& i) {
+ return (readByteUnsigned(code, i) << 8) | readByteUnsigned(code, i);
+ }
+
+ inline int readIntSigned(const uint8_t* code, unsigned& i) {
+ return ((readByteUnsigned(code, i) << 24) |
+ (readByteUnsigned(code, i) << 16) |
+ (readByteUnsigned(code, i) << 8) |
+ readByteUnsigned(code, i));
}
- inline unsigned readShortIndex(const uint8_t* code, unsigned& i) {
- return (code[++i] << 8) | code[++i];
+ inline unsigned readIntUnsigned(const uint8_t* code, unsigned& i) {
+ return readIntSigned(code, i);
}
} // namespace
@@ -105,25 +116,25 @@
opStack_.push(ConstantFP::get(Type::DoubleTy, code[i]-DCONST_0));
break;
case BIPUSH: {
- int imm = readByteImmediate(code, i);
+ int imm = readByteSigned(code, i);
opStack_.push(ConstantInt::get(Type::IntTy, imm));
break;
}
case SIPUSH: {
- int imm = readShortImmediate(code, i);
+ int imm = readShortSigned(code, i);
opStack_.push(ConstantInt::get(Type::IntTy, imm));
break;
}
case LDC: {
- unsigned index = readByteIndex(code, i);
+ unsigned index = readByteUnsigned(code, i);
// FIXME: load constant from constant pool
}
case LDC_W: {
- unsigned index = readShortIndex(code, i);
+ unsigned index = readShortUnsigned(code, i);
// FIXME: load constant from constant pool
}
case LDC2_W: {
- unsigned index = readShortIndex(code, i);
+ unsigned index = readShortUnsigned(code, i);
// FIXME: load constant from constant pool
}
case ILOAD:
@@ -132,7 +143,7 @@
case DLOAD:
case ALOAD: {
// FIXME: use opcodes to perform type checking
- unsigned index = readByteIndex(code, i);
+ unsigned index = readByteUnsigned(code, i);
opStack_.push(locals_[index]);
break;
}
More information about the llvm-commits
mailing list