Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Compilers > optimizing an a...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 2311 of 2529
Post > Topic >>

optimizing an asm-like language

by "Remo D." <rdentato@[EMAIL PROTECTED] > Jan 29, 2008 at 10:35 PM

Hi there. I'm adding the capability to generate code to my regular
expression based tool (http://yrx.googlecode.com).

I've defined an assembly-like language to use as intermediate
code. The plan is to optimize this asm-like code and then convert it
in C (or possibly other languages).

The main reason to go through this intermediate language is to apply
optimization only once rather that having to devise optimization in
each target language.

The other reason is to be able to write a function to directly execute
this asm-like program.

The first question I have is: Should I use a different approach? I
briefly thought of interpreting the DFA but it didn't seem a good idea
to me. Also, I can foresee an issue on converting the ASM language to
another language that doesn't have goto's.

The second question is: are there any optimization techniques I should
absolutely know for optimizing asm-like code?

To give you an example, the code at the bottom of this post is
generated for the expression "[a-z]?n". The meaning of the
instructions should be clear enough, except, maybe, for Rxx
(conditionl returns; RNE = Return if Not Equal, RLT = Return if Less
Then, etc) and "MTC x" (MaTCh expression, signals that the expression
x has been matched).

The things I've thought so far are:
   - rearrange basic blocks to eliminate absolute jumps (e.g. the block
labeled S2, lines 24-27, could be moved to line 14 removing the "JMP S2")
   - eliminate dead code (line 15, line 21 and line 28 for example)
   - eliminate useless JMP (like the "JMP S3" at line 20)
Should I look for other optimizations?

Any comment will be very welcome.

Remo.D


  1    S1:   GET
  2    L2:   CMP 'n'
  3          JGT L3
  4          JEQ S4
  5    L1:   CMP 'a'
  6          RLT
  7          CMP 'm'
  8          RGT
  9          JMP S2
10    L3:   CMP 'o'
11          RLT
12          CMP 'z'
13          RGT
14          JMP S2
15          RET
16    S4:   GET
17          MTC 1
18    L4:   CMP 'n'
19          RNE
20          JMP S3
21          RET
22    S3:   MTC 1
23          RET
24    S2:   GET
25    L5:   CMP 'n'
26          RNE
27          JMP S3
28          RET
 




 3 Posts in Topic:
optimizing an asm-like language
"Remo D." <r  2008-01-29 22:35:15 
Re: optimizing an asm-like language
Chris F Clark <cfc@[EM  2008-01-30 14:15:26 
Re: optimizing an asm-like language
Walter Banks <walter@[  2008-02-04 14:56:40 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 8:08:26 CDT 2008.