ge.cc

Go to the documentation of this file.
00001 #include <lestes/backend_v2/intercode/ge.g.hh>
00002 #include <lestes/md/instructions/tm_instr_base.g.hh>
00003 #include <lestes/md/types/tm_data_type_base.g.hh>
00004 #include <lestes/std/set.hh>
00005 #include <lestes/std/vector.hh>
00006 
00007 package(lestes);
00008 package(backend_v2);
00009 package(intercode);
00010 
00011 using namespace ::lestes::md::instructions;
00012 
00013 typedef vector<srp<ge_operand> >  ge_operand_vector__type;
00014 typedef vector<srp<tm_instr_op_base> >  tm_operand_vector__type;
00015 
00016 /*!
00017         \brief Returns kind of the pseudoinstruction.
00018 */
00019 ge_pi::kind_type ge_pi::kind_get()
00020 {
00021     return ge_pi::PI;
00022 }
00023 
00024 /*!
00025         \brief Returns kind of the pseudoinstruction.
00026 */
00027 ge_pi::kind_type ge_sp::kind_get()
00028 {
00029     return ge_pi::SP;
00030 }
00031 
00032 /*!
00033         \brief Returns kind of the pseudoinstruction.
00034 */
00035 ge_pi::kind_type ge_call::kind_get()
00036 {
00037     return ge_pi::CALL;
00038 }
00039 
00040 /*!
00041         \brief Tells whether the pseudoinstruction is consistent with target machine instruction that it represents.
00042         
00043         \return If the pseudoinstruction with instruction is consistent then true. False otherwise.
00044 */
00045 bool ge_pi::validate() {
00046         if ( !instruction && kind_get()!=SP ) {
00047                 return false;
00048         }
00049 
00050         ptr<ge_operand_vector__type> ge_ops = operands_input;
00051         ptr<tm_operand_vector__type> tm_ops = instruction->operands_input_get();
00052         
00053         if ( ge_ops->size() != tm_ops->size() ) {
00054                 return false;
00055         }
00056         
00057         tm_operand_vector__type::iterator it2 = tm_ops->begin();
00058         for(ge_operand_vector__type::iterator it1 = ge_ops->begin(); it1!= ge_ops->end(); ++it1, ++it2) {
00059                 ptr<ge_operand> op1 = *it1;
00060                 ptr<tm_instr_op_base> op2 = *it2;
00061                 
00062                 if ( (ulint)op1->kind_get() != (ulint)op2->kind_get() ) {
00063                         return false;
00064                 }
00065                 
00066                 if ( op2->allowed_types_get()->find(op1->type_get()->id_get())==op2->allowed_types_get()->end() ) {
00067                         return false;
00068                 }
00069         }
00070         
00071         ge_ops = operands_output;
00072         tm_ops = instruction->operands_output_get();
00073         
00074         if ( ge_ops->size() != tm_ops->size() ) {
00075                 return false;
00076         }
00077         
00078         it2 = tm_ops->begin();
00079         for(ge_operand_vector__type::iterator it1 = ge_ops->begin(); it1!= ge_ops->end(); ++it1, ++it2) {
00080                 ptr<ge_operand> op1 = *it1;
00081                 ptr<tm_instr_op_base> op2 = *it2;
00082                 
00083                 if ( (ulint)op1->kind_get() != (ulint)op2->kind_get() ) {
00084                         return false;
00085                 }
00086                 
00087                 if ( op2->allowed_types_get()->find(op1->type_get()->id_get())==op2->allowed_types_get()->end() ) {
00088                         return false;
00089                 }
00090         }
00091         
00092         return true;
00093 }
00094 
00095 
00096 /*!
00097         \brief Returns kind of the operand.
00098 */
00099 ge_operand::kind_type ge_operand_mem::kind_get()
00100 {
00101     return ge_operand::MEMORY;
00102 }
00103 
00104 
00105 /*!
00106         \brief Returns kind of the operand.
00107 */
00108 ge_operand::kind_type ge_operand_imm::kind_get()
00109 {
00110     return ge_operand::IMMEDIATE;
00111 }
00112 
00113 
00114 /*!
00115         \brief Returns kind of the operand.
00116 */
00117 ge_operand::kind_type ge_operand_reg::kind_get()
00118 {
00119     return ge_operand::REGISTER;
00120 }
00121 
00122 end_package(intercode);
00123 end_package(backend_v2);
00124 end_package(lestes);
00125 

Generated on Mon Feb 12 18:22:34 2007 for lestes by doxygen 1.5.1-20070107