< prev index next >

src/hotspot/share/adlc/adlparse.cpp

Print this page




2853 
2854 
2855 //------------------------------ins_encode_parse_block-------------------------
2856 // Parse the block form of ins_encode.  See ins_encode_parse for more details
2857 void ADLParser::ins_encode_parse_block(InstructForm& inst) {
2858   // Create a new encoding name based on the name of the instruction
2859   // definition, which should be unique.
2860   const char* prefix = "__ins_encode_";
2861   char* ec_name = (char*) AllocateHeap(strlen(inst._ident) + strlen(prefix) + 1);
2862   sprintf(ec_name, "%s%s", prefix, inst._ident);
2863 
2864   assert(_AD._encode->encClass(ec_name) == NULL, "shouldn't already exist");
2865   EncClass* encoding = _AD._encode->add_EncClass(ec_name);
2866   encoding->_linenum = linenum();
2867 
2868   // synthesize the arguments list for the enc_class from the
2869   // arguments to the instruct definition.
2870   const char* param = NULL;
2871   inst._parameters.reset();
2872   while ((param = inst._parameters.iter()) != NULL) {
2873     OperandForm* opForm = (OperandForm*) inst._localNames[param];

2874     encoding->add_parameter(opForm->_ident, param);
2875   }
2876 
2877   if (!inst._is_postalloc_expand) {
2878     // Define a MacroAssembler instance for use by the encoding.  The
2879     // name is chosen to match the __ idiom used for assembly in other
2880     // parts of hotspot and assumes the existence of the standard
2881     // #define __ _masm.
2882     encoding->add_code("    MacroAssembler _masm(&cbuf);\n");
2883   }
2884 
2885   // Parse the following %{ }% block
2886   ins_encode_parse_block_impl(inst, encoding, ec_name);
2887 
2888   // Build an encoding rule which invokes the encoding rule we just
2889   // created, passing all arguments that we received.
2890   InsEncode*   encrule = new InsEncode(); // Encode class for instruction
2891   NameAndList* params  = encrule->add_encode(ec_name);
2892   inst._parameters.reset();
2893   while ((param = inst._parameters.iter()) != NULL) {


3323 
3324 
3325 //------------------------------constant_parse---------------------------------
3326 // Parse a constant expression.
3327 void ADLParser::constant_parse(InstructForm& inst) {
3328   // Create a new encoding name based on the name of the instruction
3329   // definition, which should be unique.
3330   const char* prefix = "__constant_";
3331   char* ec_name = (char*) AllocateHeap(strlen(inst._ident) + strlen(prefix) + 1);
3332   sprintf(ec_name, "%s%s", prefix, inst._ident);
3333 
3334   assert(_AD._encode->encClass(ec_name) == NULL, "shouldn't already exist");
3335   EncClass* encoding = _AD._encode->add_EncClass(ec_name);
3336   encoding->_linenum = linenum();
3337 
3338   // synthesize the arguments list for the enc_class from the
3339   // arguments to the instruct definition.
3340   const char* param = NULL;
3341   inst._parameters.reset();
3342   while ((param = inst._parameters.iter()) != NULL) {
3343     OperandForm* opForm = (OperandForm*) inst._localNames[param];

3344     encoding->add_parameter(opForm->_ident, param);
3345   }
3346 
3347   // Parse the following ( ) expression.
3348   constant_parse_expression(encoding, ec_name);
3349 
3350   // Build an encoding rule which invokes the encoding rule we just
3351   // created, passing all arguments that we received.
3352   InsEncode*   encrule = new InsEncode(); // Encode class for instruction
3353   NameAndList* params  = encrule->add_encode(ec_name);
3354   inst._parameters.reset();
3355   while ((param = inst._parameters.iter()) != NULL) {
3356     params->add_entry(param);
3357   }
3358 
3359   // Set encode class of this instruction.
3360   inst._constant = encrule;
3361 }
3362 
3363 




2853 
2854 
2855 //------------------------------ins_encode_parse_block-------------------------
2856 // Parse the block form of ins_encode.  See ins_encode_parse for more details
2857 void ADLParser::ins_encode_parse_block(InstructForm& inst) {
2858   // Create a new encoding name based on the name of the instruction
2859   // definition, which should be unique.
2860   const char* prefix = "__ins_encode_";
2861   char* ec_name = (char*) AllocateHeap(strlen(inst._ident) + strlen(prefix) + 1);
2862   sprintf(ec_name, "%s%s", prefix, inst._ident);
2863 
2864   assert(_AD._encode->encClass(ec_name) == NULL, "shouldn't already exist");
2865   EncClass* encoding = _AD._encode->add_EncClass(ec_name);
2866   encoding->_linenum = linenum();
2867 
2868   // synthesize the arguments list for the enc_class from the
2869   // arguments to the instruct definition.
2870   const char* param = NULL;
2871   inst._parameters.reset();
2872   while ((param = inst._parameters.iter()) != NULL) {
2873     OpClassForm* opForm = inst._localNames[param]->is_opclass();
2874     assert(opForm != NULL, "sanity");
2875     encoding->add_parameter(opForm->_ident, param);
2876   }
2877 
2878   if (!inst._is_postalloc_expand) {
2879     // Define a MacroAssembler instance for use by the encoding.  The
2880     // name is chosen to match the __ idiom used for assembly in other
2881     // parts of hotspot and assumes the existence of the standard
2882     // #define __ _masm.
2883     encoding->add_code("    MacroAssembler _masm(&cbuf);\n");
2884   }
2885 
2886   // Parse the following %{ }% block
2887   ins_encode_parse_block_impl(inst, encoding, ec_name);
2888 
2889   // Build an encoding rule which invokes the encoding rule we just
2890   // created, passing all arguments that we received.
2891   InsEncode*   encrule = new InsEncode(); // Encode class for instruction
2892   NameAndList* params  = encrule->add_encode(ec_name);
2893   inst._parameters.reset();
2894   while ((param = inst._parameters.iter()) != NULL) {


3324 
3325 
3326 //------------------------------constant_parse---------------------------------
3327 // Parse a constant expression.
3328 void ADLParser::constant_parse(InstructForm& inst) {
3329   // Create a new encoding name based on the name of the instruction
3330   // definition, which should be unique.
3331   const char* prefix = "__constant_";
3332   char* ec_name = (char*) AllocateHeap(strlen(inst._ident) + strlen(prefix) + 1);
3333   sprintf(ec_name, "%s%s", prefix, inst._ident);
3334 
3335   assert(_AD._encode->encClass(ec_name) == NULL, "shouldn't already exist");
3336   EncClass* encoding = _AD._encode->add_EncClass(ec_name);
3337   encoding->_linenum = linenum();
3338 
3339   // synthesize the arguments list for the enc_class from the
3340   // arguments to the instruct definition.
3341   const char* param = NULL;
3342   inst._parameters.reset();
3343   while ((param = inst._parameters.iter()) != NULL) {
3344     OpClassForm* opForm = inst._localNames[param]->is_opclass();
3345     assert(opForm != NULL, "sanity");
3346     encoding->add_parameter(opForm->_ident, param);
3347   }
3348 
3349   // Parse the following ( ) expression.
3350   constant_parse_expression(encoding, ec_name);
3351 
3352   // Build an encoding rule which invokes the encoding rule we just
3353   // created, passing all arguments that we received.
3354   InsEncode*   encrule = new InsEncode(); // Encode class for instruction
3355   NameAndList* params  = encrule->add_encode(ec_name);
3356   inst._parameters.reset();
3357   while ((param = inst._parameters.iter()) != NULL) {
3358     params->add_entry(param);
3359   }
3360 
3361   // Set encode class of this instruction.
3362   inst._constant = encrule;
3363 }
3364 
3365 


< prev index next >