mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-19 18:24:00 +00:00
Remove CLocalVars data structure entirely, instead of building stuff and
then printing it out, just print as we go. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2585 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -8,7 +8,6 @@
|
|||||||
//===-----------------------------------------------------------------------==//
|
//===-----------------------------------------------------------------------==//
|
||||||
|
|
||||||
#include "llvm/Assembly/CWriter.h"
|
#include "llvm/Assembly/CWriter.h"
|
||||||
#include "CLocalVars.h"
|
|
||||||
#include "llvm/SlotCalculator.h"
|
#include "llvm/SlotCalculator.h"
|
||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
@ -32,21 +31,8 @@
|
|||||||
#include <strstream>
|
#include <strstream>
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::map;
|
using std::map;
|
||||||
using std::vector;
|
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
|
|
||||||
//===-----------------------------------------------------------------------==//
|
|
||||||
//
|
|
||||||
// Implementation of the CLocalVars methods
|
|
||||||
|
|
||||||
// Appends a variable to the LocalVars map if it does not already exist
|
|
||||||
// Also check that the type exists on the map.
|
|
||||||
void CLocalVars::addLocalVar(const Type *t, const string &V) {
|
|
||||||
if (!LocalVars.count(t) ||
|
|
||||||
find(LocalVars[t].begin(), LocalVars[t].end(), V) == LocalVars[t].end())
|
|
||||||
LocalVars[t].push_back(V);
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string getConstStrValue(const Constant* CPV);
|
static std::string getConstStrValue(const Constant* CPV);
|
||||||
|
|
||||||
|
|
||||||
@ -746,22 +732,11 @@ void CWriter::printFunction(Function *F) {
|
|||||||
printFunctionSignature(F);
|
printFunctionSignature(F);
|
||||||
Out << " {\n";
|
Out << " {\n";
|
||||||
|
|
||||||
// Process each of the basic blocks, gather information and call the
|
// print local variable information for the function
|
||||||
// output methods on the CLocalVars and Function* objects.
|
|
||||||
|
|
||||||
// gather local variable information for each basic block
|
|
||||||
CLocalVars CLV;
|
|
||||||
for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I)
|
for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I)
|
||||||
if ((*I)->getType() != Type::VoidTy)
|
if ((*I)->getType() != Type::VoidTy) {
|
||||||
CLV.addLocalVar((*I)->getType(), getValueName(*I));
|
|
||||||
|
|
||||||
// print the local variables
|
|
||||||
for (map<const Type*, VarListType>::iterator I = CLV.LocalVars.begin(),
|
|
||||||
E = CLV.LocalVars.end(); I != E; ++I)
|
|
||||||
for (VarListType::iterator TI = I->second.begin(), E = I->second.end();
|
|
||||||
TI != E; ++TI) {
|
|
||||||
Out << " ";
|
Out << " ";
|
||||||
printTypeVar(I->first, *TI);
|
printTypeVar((*I)->getType(), getValueName(*I));
|
||||||
Out << ";\n";
|
Out << ";\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
//===-----------------------------------------------------------------------==//
|
//===-----------------------------------------------------------------------==//
|
||||||
|
|
||||||
#include "llvm/Assembly/CWriter.h"
|
#include "llvm/Assembly/CWriter.h"
|
||||||
#include "CLocalVars.h"
|
|
||||||
#include "llvm/SlotCalculator.h"
|
#include "llvm/SlotCalculator.h"
|
||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
@ -32,21 +31,8 @@
|
|||||||
#include <strstream>
|
#include <strstream>
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::map;
|
using std::map;
|
||||||
using std::vector;
|
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
|
|
||||||
//===-----------------------------------------------------------------------==//
|
|
||||||
//
|
|
||||||
// Implementation of the CLocalVars methods
|
|
||||||
|
|
||||||
// Appends a variable to the LocalVars map if it does not already exist
|
|
||||||
// Also check that the type exists on the map.
|
|
||||||
void CLocalVars::addLocalVar(const Type *t, const string &V) {
|
|
||||||
if (!LocalVars.count(t) ||
|
|
||||||
find(LocalVars[t].begin(), LocalVars[t].end(), V) == LocalVars[t].end())
|
|
||||||
LocalVars[t].push_back(V);
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string getConstStrValue(const Constant* CPV);
|
static std::string getConstStrValue(const Constant* CPV);
|
||||||
|
|
||||||
|
|
||||||
@ -746,22 +732,11 @@ void CWriter::printFunction(Function *F) {
|
|||||||
printFunctionSignature(F);
|
printFunctionSignature(F);
|
||||||
Out << " {\n";
|
Out << " {\n";
|
||||||
|
|
||||||
// Process each of the basic blocks, gather information and call the
|
// print local variable information for the function
|
||||||
// output methods on the CLocalVars and Function* objects.
|
|
||||||
|
|
||||||
// gather local variable information for each basic block
|
|
||||||
CLocalVars CLV;
|
|
||||||
for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I)
|
for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I)
|
||||||
if ((*I)->getType() != Type::VoidTy)
|
if ((*I)->getType() != Type::VoidTy) {
|
||||||
CLV.addLocalVar((*I)->getType(), getValueName(*I));
|
|
||||||
|
|
||||||
// print the local variables
|
|
||||||
for (map<const Type*, VarListType>::iterator I = CLV.LocalVars.begin(),
|
|
||||||
E = CLV.LocalVars.end(); I != E; ++I)
|
|
||||||
for (VarListType::iterator TI = I->second.begin(), E = I->second.end();
|
|
||||||
TI != E; ++TI) {
|
|
||||||
Out << " ";
|
Out << " ";
|
||||||
printTypeVar(I->first, *TI);
|
printTypeVar((*I)->getType(), getValueName(*I));
|
||||||
Out << ";\n";
|
Out << ";\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user