[llvm-commits] CVS: llvm/tools/jello/GlobalVars.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Dec 12 09:34:03 PST 2002


Changes in directory llvm/tools/jello:

GlobalVars.cpp updated: 1.1 -> 1.2

---
Log message:


This checkin is brought to you by the brian gaeke allnighter fund.


(lib/Target/X86) InstSelectSimple.cpp: 
 Include llvm/DerivedTypes.h and iostream.
 Refactor visitMul out into a wrapper around doMultiply(), so that we
  can do multiplications on temporary values when we are doing
  getelementptrs.
 Refactor part of getReg out into makeAnotherReg, so that we can create
  registers willy-nilly to hold temporary values, when we are doing
  getelementptrs.
 Add stub implementations of visitMallocInst and visitAllocaInst.
 Add initial implementation of visitGetElementPtrInst.
 In copyConstantToRegister: 
  We throw a *lot* of our asserts here. So, when we want to throw an
   assert, print out to stderr whatever expr or whatever constant made
   us barf.
  Support copying ConstantPointerNull to register, using a move immediate
   of zero.
 Rename FLDr4 and FLDr8 to FLDr32 and FLDr64, so that they match the meanings
  of the numbers in the other instruction names. All uses modified.
 Teach visitCallInst to extract byte- and short-class return values
  from subregs of EAX.  Add a FIXME note about how we would do it for
  float-class return values.
 Add a FIXME note about how we would cast float to int and back.

X86InstrInfo.def:
 Rename FLDr4 and FLDr8 to FLDr32 and FLDr64, so that they match the meanings
  of the numbers in the other instruction names. All uses modified.

(tools/jello) GlobalVars.cpp:
 Include iostream.
 If we have to emit a floating-point constant to memory, gamble and use
  the same method as for ints.
 If we have to emit a ConstantPointerNull to memory, try using a "void *"
  and "NULL".
 Otherwise, if we are going to throw an assert, print out whatever constant
  made us barf, first.


---
Diffs of the changes:

Index: llvm/tools/jello/GlobalVars.cpp
diff -u llvm/tools/jello/GlobalVars.cpp:1.1 llvm/tools/jello/GlobalVars.cpp:1.2
--- llvm/tools/jello/GlobalVars.cpp:1.1	Wed Dec  4 00:09:04 2002
+++ llvm/tools/jello/GlobalVars.cpp	Thu Dec 12 09:33:40 2002
@@ -9,6 +9,7 @@
 #include "llvm/Constants.h"
 #include "llvm/Target/TargetMachine.h"
 #include "VM.h"
+#include <iostream>
 
 /// EmitGlobals - Emit all of the global variables to memory, storing their
 /// addresses into GlobalAddress.  This must make sure to copy the contents of
@@ -77,6 +78,20 @@
       return;
     default: break;
     }
+  } else if (ConstantFP *CF = dyn_cast <ConstantFP> (Init)) {
+    switch (CF->getType ()->getPrimitiveID ()) {
+    case Type::FloatTyID:
+      *(float*)Addr = CF->getValue ();
+      return;
+    case Type::DoubleTyID:
+      *(double*)Addr = CF->getValue ();
+      return;
+    default: break;
+    }
+  } else if (ConstantPointerNull *CP = dyn_cast <ConstantPointerNull> (Init)) {
+	// Fill the space with a NULL pointer.
+	*(void **)Addr = NULL;
+	return;
   } else if (ConstantArray *CA = dyn_cast<ConstantArray>(Init)) {
     unsigned ElementSize = TD.getTypeSize(CA->getType()->getElementType());
     for (unsigned i = 0, e = CA->getType()->getNumElements(); i != e; ++i) {
@@ -86,5 +101,6 @@
     return;
   }
 
+  std::cerr << "Offending constant: " << Init << "\n";
   assert(0 && "Don't know how to emit this constant to memory!");
 }





More information about the llvm-commits mailing list