1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <fstream>
using std::cout;
using std::cerr;
using std::endl;
using std::ostream;
using std::string;
using std::setfill;
using std::setbase;
using std::vector;
using std::setw;
using std::ios;
using std::ofstream;
#ifndef __STRING
#if defined __STDC__ && __STDC__
#define __STRING(x) #x
#else
#define __STRING(x) "x"
#endif
#endif
void bg_out(const string &fname)
{
ofstream o;
o.open(fname.c_str());
if(o.fail())
{
cerr << "error: could not open `" << fname << "` for writing" << endl;
exit(1);
}
o << setfill('0') << setbase(16);
o.setf(ios::uppercase);
#define USECODE_INTRINSIC_PTR(NAME) std::string(__STRING(NAME))
std::string bgut[] =
{
#include "bgintrinsics.h"
};
#undef USECODE_INTRINSIC_PTR
o << "<intrinsics>" << endl;
for(unsigned int i=0; i<0x100; i++)
o << "\t<0x" << setw(2) << i << "> " << bgut[i] << "_" << setw(2) << i << " </>" << endl;
o << "</>" << endl;
o.close();
}
void si_out(const string &fname)
{
ofstream o;
o.open(fname.c_str());
if(o.fail())
{
cerr << "error: could not open `" << fname << "` for writing" << endl;
exit(1);
}
o << setfill('0') << setbase(16);
o.setf(ios::uppercase);
#define USECODE_INTRINSIC_PTR(NAME) std::string(__STRING(NAME))
std::string siut[] =
{
#include "siintrinsics.h"
};
#undef USECODE_INTRINSIC_PTR
o << "<intrinsics>" << endl;
for(unsigned int i=0; i<0x100; i++)
o << "\t<0x" << setw(2) << i << "> " << siut[i] << "_" << setw(2) << i << " </>" << endl;
o << "</>" << endl;
o.close();
}
int main(int argc, char **argv)
{
if(argc!=3)
{
cout << "usage:" << endl
<< "\thead2data <bg outputfile> <si outputfile>" << endl
<< endl
<< "\tWhere the output files are the relative pathnames to the datafiles" << endl
<< "\tto be output." << endl
<< "\teg. head2data data/u7bgintrinsics.data data/u7siintrinsics.data" << endl;
return 1;
}
bg_out(string(argv[1]));
si_out(string(argv[2]));
return 0;
}
|