Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

How to compile arithmetic expressions to x86?

Name: Anonymous 2015-07-10 21:16

hi prog, say I want to take as given some variables on the stack x,y,z,w and compile expressions (x+y)*(z+w) to x86 asm.

first off the instructions take registers or pointers and well x86 is weird and has instructions like this:

add x, y ;x OR y must be a register, result in x
mul x ;multiplies eax with x, result is put into eax


so this would work:

mov eax, stack0
add eax, stack1
mov ebx, stack2
add ebx, stack3
mul ebx


but how would you make an algorithm to do this in general?

Name: Anonymous 2015-07-19 17:36

>>40
Ullman FUCK ! What a Piece of shit !!!

Name: Anonymous 2015-07-19 18:24

I want to learn Krav Maga to beat shit out of goyim.

Name: Anonymous 2015-07-19 18:26

>>39
stop posting or stop using a name you fucking retard

Name: Anonymous 2015-07-19 21:18

>>43
implying a retard can understand he behaves like a retard

Name: Anonymous 2015-07-19 21:26

>>44
Who are you quoting?

Name: Anonymous 2015-07-19 21:36

>>44
Using retarded /g/ memes is worse than using a name, you know. Also, Cudder is way older than your failure of a teenager mom.

Name: Anonymous 2015-07-19 21:57

>>46
Hello, Cudder!

Name: Anonymous 2015-07-19 22:27

>>46
Old Cudder-fag had a clam, HE-HI-HE-HI-HO
And on his clam he had some dicks, HE-HI-HE-HI-HO

With a dick, dick here, and a dick, dick there,
Here a dick, there a dick, everywhere a dick, dick,

Name: Anonymous 2015-07-19 22:39

>>43-48
NOT VIP QUALITY

Name: You sire are and idiot 2015-07-19 23:06

>>49
including 43 in that
no, fuck you

Name: Anonymous 2015-07-19 23:15

>>50
Excuse me, dear Sir, would you be so kind to tell us what is the origin of your quotation?

Name: Anonymous 2015-07-20 0:56

>>50
NOT VIP QUALITY

Name: Anonymous 2015-07-20 2:57

das rite!

Name: Anonymous 2015-07-20 5:47

>>50
What do you have against Cudder?

Name: Anonymous 2015-07-21 1:18

You guys havent helpde me much but I figured out a bit more myself:

SOME IDEA ABOUT A NEW IL:

dest <- dest + src
x y + z

edx:eax <- eax * r/m32

data AS
= Add Var Var Var -- 2 or 3 -- must be 3!
| Mul Var Var Var Var -- 4

NEED 3 because its not SSA otherwise!

(insert a mov before or after ?)

y ) ( x
--------- Add x y z ---------
precolor graph with: x = y (this probably breaks the coloring algorithms though..)

z ) ( x y
------- Mul x y z w ---------
precolor graph with: x red, y blue

Lets work an example by hand:

(a * b) + (c * d)

Set u2 a
Set u3 b
Set v2 c
Set v3 d
Mul u0:u1 u2 u3
Mul v0:v1 v2 v3
Add r u1 v1

lifetimes:

set set mul mul add end
. . . . . . . |
u0 --------------..
u1 ---------
u2---------
u3 ---------------------..
v0 -----------..
v1 ------
v2 ---------
v3 -----------------..

now coloring that should give a good allocation

Name: Cudder !cXCudderUE 2015-07-21 11:05

Forget graph colouring, it's stupid academic circlejerk bullshite. Work backwards from dataflow and use something closer to bin-packing if you want to do better than existing compilers and be closer to LLVM.

Name: Anonymous 2015-07-21 14:56

Cudder is all talk and no action.

Name: Anonymous 2015-07-21 15:16

>>56
fuck off, dont post with a name in my thread

>>57
fuck off

Name: Anonymous 2015-07-21 16:24

>>58
you first

Name: Anonymous 2015-07-21 19:48

>>56
Why would I want to approximate LLVM? It already exists, right?

Name: Anonymous 2015-07-21 20:00

color my anus

Name: Cudder !cXCudderUE 2015-07-22 5:11

>>60
LLVM doesn't use graph colouring and is better because of it.

http://blog.llvm.org/2011/09/greedy-register-allocation-in-llvm-30.html

Name: Anonymous 2016-01-01 16:49

C is turdware.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List