-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from adi-lb-phoenix/branch_3
Introduce more types and add type conversion
- Loading branch information
Showing
29 changed files
with
367 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
64 | ||
226 | ||
1 | ||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
;not verified as llvm is not being emitted when doing bitcast from same number of bits to same number of bits. | ||
(brilisp | ||
(define ((print int32) (n int32))) | ||
|
||
(define ((custom_print int32) (n int8)) | ||
(set (n_int32 int) (zext n int)) | ||
(set (tmp int) (call print n_int32)) | ||
(ret tmp)) | ||
|
||
(define ((main void)) | ||
(set (size int) (const 1)) | ||
(set (int32_arr (ptr int)) (alloc size)) | ||
|
||
(set (value int) (const 123456)) | ||
(store int32_arr value) | ||
|
||
(set (int8_arr (ptr int8)) (bitcast int32_arr int8)) | ||
|
||
; int8_arr[0] | ||
(set (out_val int8) (load int8_arr)) | ||
(set (tmp int) (call custom_print out_val)) | ||
|
||
; int8_arr[1] | ||
(set (array_idx int) (const 1)) | ||
(set (int8_arr_idx (ptr int8)) (ptradd int8_arr array_idx)) | ||
(set (out_val int8) (load int8_arr_idx)) | ||
(set (tmp int) (call custom_print out_val)) | ||
|
||
; int8_arr[2] | ||
(set (array_idx int) (const 2)) | ||
(set (int8_arr_idx (ptr int8)) (ptradd int8_arr array_idx)) | ||
(set (out_val int8) (load int8_arr_idx)) | ||
(set (tmp int) (call custom_print out_val)) | ||
|
||
; int8_arr[3] | ||
(set (array_idx int) (const 3)) | ||
(set (int8_arr_idx (ptr int8)) (ptradd int8_arr array_idx)) | ||
(set (out_val int8) (load int8_arr_idx)) | ||
(set (tmp int) (call custom_print out_val)) | ||
|
||
(ret))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.125000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
;%X = fpext float 3.125 to double ; yields double:3.125000e+00 | ||
; %Y = fpext double %X to fp128; yields fp128:0xL00000000000000004000900000000000 llvmlit for fp128 not found | ||
(brilisp | ||
(define ((dprint double) (n double))) | ||
|
||
(define ((main void)) | ||
(set (a float) (const 3.125)) | ||
(set (b double) (fpext a double)) | ||
(set (tmp double) (call dprint b)) | ||
(ret))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-4 | ||
14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
(brilisp | ||
(define ((print int) (n int))) | ||
|
||
(define ((main int)) | ||
;testing fptosi on a floating point number | ||
(set (five int) (const 5)) | ||
(set (a float) (const -9.7123)) | ||
(set (f_n int) (fptosi a int)) | ||
(set (sum int) (add f_n five)) | ||
(set (tmp int) (call print sum)) | ||
|
||
;testing fptosi on a integer number | ||
(set (c int) (const 9)) | ||
(set (f_n int) (fptosi c int)) | ||
(set (sum int) (add f_n five)) | ||
(set (tmp int) (call print sum)) | ||
|
||
(ret tmp))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
123 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
;%Y = fptoui float 1.0E+300 to i1 ; yields undefined:1 | ||
;%Z = fptoui float 1.04E+17 to i8 ; yields undefined:1 left to implement | ||
|
||
(brilisp | ||
(define ((print int32) (n int32))) | ||
|
||
(define ((main void)) | ||
(set (a double) (const 123.0)) | ||
(set (f_n int32) (fptoui a int32)) | ||
(set (tmp int32) (call print f_n)) | ||
(ret))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
16777216.000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
;test for fptrunc double 1.0E+300 to half not done | ||
(brilisp | ||
(define ((fprint float) (n float))) | ||
|
||
(define ((main void)) | ||
(set (a double) (const 16777217.0)) | ||
(set (f_n float) (fptrunc a float)) | ||
(set (tmp float) (call fprint f_n)) | ||
(ret))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
0xffffff01 | ||
-255 | ||
0xff | ||
255 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(brilisp | ||
(define ((print int) (n int))) | ||
|
||
(define ((ptr_print (ptr int)) (n (ptr int)))) | ||
|
||
(define ((main void)) | ||
(set (a int) (const -255)) | ||
|
||
; we will convert an integer to pointer value. | ||
(set (pointer_returned (ptr int)) (inttoptr a (ptr int))) | ||
(set (return_print_1 (ptr int)) (call ptr_print pointer_returned)) | ||
|
||
; convert the returned pointer value to int. | ||
(set (return_value int) (ptrtoint pointer_returned int)) | ||
(set (return_print_2 int) (call print return_value)) | ||
|
||
; repeating the above process for a +ve int. | ||
(set (d int) (const 255)) | ||
|
||
; we will convert an integer to pointer value. | ||
(set (pointer_returned_1 (ptr int)) (inttoptr d (ptr int))) | ||
(set (return_print_3 (ptr int)) (call ptr_print pointer_returned_1)) | ||
|
||
; convert the returned pointer value to int. | ||
(set (return_value_1 int) (ptrtoint pointer_returned_1 int)) | ||
(set (return_print_4 int) (call print return_value_1)) | ||
(ret))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-1 | ||
127 | ||
255 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
;test for sext i1 true to i32 not completed | ||
(brilisp | ||
(define ((print int) (n int))) | ||
|
||
(define ((main void)) | ||
(set (a int8) (const -1)) | ||
(set (f_n int) (sext a int)) | ||
(set (tmp int) (call print f_n)) | ||
|
||
(set (b int8) (const 127)) | ||
(set (f_n int) (sext b int)) | ||
(set (tmp int) (call print f_n)) | ||
|
||
; test zext too | ||
(set (f_n int) (zext a int)) | ||
(set (tmp int) (call print f_n)) | ||
(ret))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-3.920000 | ||
14.130000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
(brilisp | ||
(define ((fprint float) (n float))) | ||
(define ((dprint double) (n double))) | ||
|
||
(define ((main void)) | ||
;testing for float to float conversion with a negative float value. | ||
(set (a float) (const -9.12)) | ||
(set (five float) (const 5.2)) | ||
(set (f_n float) (sitofp a float)) | ||
(set (sum float) (fadd f_n five)) | ||
(set (tmp float) (call fprint sum)) | ||
|
||
;testing for int to float conversion with a postive int | ||
(set (c int) (const 9)) | ||
(set (five double) (const 5.13)) | ||
(set (f_n double) (sitofp c double)) | ||
(set (sum double) (fadd f_n five)) | ||
(set (tmp double) (call dprint sum)) | ||
(ret))) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
127 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(brilisp | ||
(define ((print int) (n int))) | ||
|
||
(define (( main void)) | ||
(set (a int) (const 127)) | ||
(set (f_n int8) (trunc a int8)) | ||
(set (a_n int) (sext f_n int)) | ||
(set (tmp int) (call print a_n)) | ||
(ret))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
(brilisp | ||
(define ((print int8) (n int8))) | ||
|
||
(define ((main void)) | ||
(set (a int32) (const 257)) | ||
(set (f_n int8) (trunc a int8)) | ||
(set (tmp int8) (call print f_n)) | ||
(ret))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
257.000000 | ||
255.000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(brilisp | ||
(define ((fprint float) (n float))) | ||
(define ((dprint double) (n double))) | ||
|
||
(define ((main void)) | ||
(set (a int32) (const 257)) | ||
(set (b float) (uitofp a float)) | ||
(set (tmp float) (call fprint b)) | ||
|
||
(set (a int8) (const -1)) | ||
(set (b double) (uitofp a double)) | ||
(set (tmp double) (call dprint b)) | ||
(ret))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
257 | ||
65535 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
;test fo zext i1 true to i32 not completed. | ||
(brilisp | ||
(define ((print int) (n int))) | ||
|
||
(define ((main void)) | ||
(set (a int16) (const 257)) | ||
(set (b int) (zext a int)) | ||
(set (tmp int) (call print b)) | ||
|
||
(set (a int16) (const -1)) | ||
(set (b int) (zext a int)) | ||
(set (tmp int) (call print b)) | ||
(ret))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-128 | ||
127 | ||
127 | ||
-128 | ||
-32768 | ||
32767 | ||
32767 | ||
-32768 | ||
-2147483648 | ||
2147483647 | ||
2147483647 | ||
-2147483648 | ||
-9223372036854775808 | ||
9223372036854775807 | ||
9223372036854775807 | ||
-9223372036854775808 |
Oops, something went wrong.