LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

MachineConstantPool.h

Go to the documentation of this file.
00001 //===-- CodeGen/MachineConstantPool.h - Abstract Constant Pool --*- C++ -*-===//
00002 // 
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by the LLVM research group and is distributed under
00006 // the University of Illinois Open Source License. See LICENSE.TXT for details.
00007 // 
00008 //===----------------------------------------------------------------------===//
00009 // 
00010 // The MachineConstantPool class keeps track of constants referenced by a
00011 // function which must be spilled to memory.  This is used for constants which
00012 // are unable to be used directly as operands to instructions, which typically
00013 // include floating point and large integer constants.
00014 //
00015 // Instructions reference the address of these constant pool constants through
00016 // the use of MO_ConstantPoolIndex values.  When emitting assembly or machine
00017 // code, these virtual address references are converted to refer to the
00018 // address of the function constant pool values.
00019 //
00020 //===----------------------------------------------------------------------===//
00021 
00022 #ifndef LLVM_CODEGEN_MACHINECONSTANTPOOL_H
00023 #define LLVM_CODEGEN_MACHINECONSTANTPOOL_H
00024 
00025 #include <vector>
00026 
00027 namespace llvm {
00028 
00029 class Constant;
00030 
00031 class MachineConstantPool {
00032   std::vector<Constant*> Constants;
00033 public:
00034 
00035   /// getConstantPoolIndex - Create a new entry in the constant pool or return
00036   /// an existing one.
00037   ///
00038   unsigned getConstantPoolIndex(Constant *C) {
00039     // Check to see if we already have this constant.
00040     //
00041     // FIXME, this could be made much more efficient for large constant pools.
00042     for (unsigned i = 0, e = Constants.size(); i != e; ++i)
00043       if (Constants[i] == C)
00044         return i;
00045     Constants.push_back(C);
00046     return Constants.size()-1;
00047   }
00048 
00049   const std::vector<Constant*> &getConstants() const { return Constants; }
00050 
00051   /// print - Used by the MachineFunction printer to print information about
00052   /// stack objects.  Implemented in MachineFunction.cpp
00053   ///
00054   void print(std::ostream &OS) const;
00055 
00056   /// dump - Call print(std::cerr) to be called from the debugger.
00057   void dump() const;
00058 };
00059 
00060 } // End llvm namespace
00061 
00062 #endif