00001
00002 #ifdef HAVE_CONFIG_H
00003 #include <config.h>
00004 #endif
00005
00006 #include <iostream>
00007 #include <string>
00008 #include <iomanip>
00009 #include <vector>
00010 #include <fstream>
00011
00012 using std::cout;
00013 using std::cerr;
00014 using std::endl;
00015 using std::ostream;
00016 using std::string;
00017 using std::setfill;
00018 using std::setbase;
00019 using std::vector;
00020 using std::setw;
00021 using std::ios;
00022 using std::ofstream;
00023
00024 #ifndef __STRING
00025 #if defined __STDC__ && __STDC__
00026 #define __STRING(x) #x
00027 #else
00028 #define __STRING(x) "x"
00029 #endif
00030 #endif
00031
00032 void bg_out(const string &fname)
00033 {
00034 ofstream o;
00035 o.open(fname.c_str());
00036
00037 if(o.fail())
00038 {
00039 cerr << "error: could not open `" << fname << "` for writing" << endl;
00040 exit(1);
00041 }
00042
00043 o << setfill('0') << setbase(16);
00044 o.setf(ios::uppercase);
00045
00046 #define USECODE_INTRINSIC_PTR(NAME) std::string(__STRING(NAME))
00047 std::string bgut[] =
00048 {
00049 #include "bgintrinsics.h"
00050 };
00051 #undef USECODE_INTRINSIC_PTR
00052
00053 o << "<intrinsics>" << endl;
00054 for(unsigned int i=0; i<0x100; i++)
00055 o << "\t<0x" << setw(2) << i << "> " << bgut[i] << "_" << setw(2) << i << " </>" << endl;
00056 o << "</>" << endl;
00057
00058 o.close();
00059 }
00060
00061 void si_out(const string &fname)
00062 {
00063 ofstream o;
00064 o.open(fname.c_str());
00065
00066 if(o.fail())
00067 {
00068 cerr << "error: could not open `" << fname << "` for writing" << endl;
00069 exit(1);
00070 }
00071
00072 o << setfill('0') << setbase(16);
00073 o.setf(ios::uppercase);
00074
00075 #define USECODE_INTRINSIC_PTR(NAME) std::string(__STRING(NAME))
00076 std::string siut[] =
00077 {
00078 #include "siintrinsics.h"
00079 };
00080 #undef USECODE_INTRINSIC_PTR
00081
00082 o << "<intrinsics>" << endl;
00083 for(unsigned int i=0; i<0x100; i++)
00084 o << "\t<0x" << setw(2) << i << "> " << siut[i] << "_" << setw(2) << i << " </>" << endl;
00085 o << "</>" << endl;
00086
00087 o.close();
00088 }
00089
00090 int main(int argc, char **argv)
00091 {
00092 if(argc!=3)
00093 {
00094 cout << "usage:" << endl
00095 << "\thead2data <bg outputfile> <si outputfile>" << endl
00096 << endl
00097 << "\tWhere the output files are the relative pathnames to the datafiles" << endl
00098 << "\tto be output." << endl
00099 << "\teg. head2data data/u7bgintrinsics.data data/u7siintrinsics.data" << endl;
00100 return 1;
00101 }
00102
00103 bg_out(string(argv[1]));
00104 si_out(string(argv[2]));
00105
00106 return 0;
00107 }
00108