- /*ctor*/ MachineCodeForMethod(Method* _M)
- : method(_M), compiledAsLeaf(false), staticStackSize(0),
- automaticVarsSize(0), regSpillsSize(0), optionalOutgoingArgsSize(0) {}
-
- inline bool isCompiledAsLeafMethod() const { return compiledAsLeaf; }
- inline unsigned getStaticStackSize() const { return staticStackSize; }
- inline unsigned getAutomaticVarsSize() const { return automaticVarsSize; }
- inline unsigned getRegSpillsSize() const { return regSpillsSize; }
- inline unsigned getOptionalOutgoingArgsSize() const
- { return optionalOutgoingArgsSize; }
+ /*ctor*/ MachineCodeForMethod(const Method* method,
+ const TargetMachine& target);
+
+ // The next two methods are used to construct and to retrieve
+ // the MachineCodeForMethod object for the given method.
+ // construct() -- Allocates and initializes for a given method and target
+ // get() -- Returns a handle to the object.
+ // This should not be called before "construct()"
+ // for a given Method.
+ //
+ inline static MachineCodeForMethod& construct(const Method* method,
+ const TargetMachine& target)
+ {
+ assert(method->getAnnotation(MachineCodeForMethod::AID) == NULL &&
+ "Object already exists for this method!");
+ MachineCodeForMethod* mcInfo = new MachineCodeForMethod(method, target);
+ method->addAnnotation(mcInfo);
+ return *mcInfo;
+ }
+
+ inline static MachineCodeForMethod& get(const Method* method)
+ {
+ MachineCodeForMethod* mc = (MachineCodeForMethod*)
+ method->getAnnotation(MachineCodeForMethod::AID);
+ assert(mc && "Call construct() method first to allocate the object");
+ return *mc;
+ }
+
+ //
+ // Accessors for global information about generated code for a method.
+ //
+ inline bool isCompiledAsLeafMethod() const { return compiledAsLeaf; }
+ inline unsigned getStaticStackSize() const { return staticStackSize; }
+ inline unsigned getAutomaticVarsSize() const { return automaticVarsSize; }
+ inline unsigned getRegSpillsSize() const { return regSpillsSize; }
+ inline unsigned getMaxOptionalArgsSize() const { return maxOptionalArgsSize;}
+ inline unsigned getCurrentOptionalArgsSize() const
+ { return currentOptionalArgsSize;}