Sei sulla pagina 1di 3

 

COMPILERS 

HW-1 
Sawar Sagwal (2017013) 
 

Question 1  
The gcc version was found by using the following command: 

gcc --version 

Output: 

gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0  

gcc version is 9.3.0, gcc-10 was installed in parallel as non-default. 

Question 2  
The basic LLVM (without any additional support took time to install: 8
​ 3min 29sec 

Code for LLVM is written in c++. It can be compiled using a c++ compiler, here it was g++ 
compiler. 

Question 3 
The following test.c file was used: 

#include ​<stdio.h>
void​ main()
{
int​ sum = ​0​;
for​(​int​ i = ​0​ ; i < ​10000​ ; ++i)
{
sum = sum + i;
}

 
 

 
 
 
 
 
 
x86_64: 
a.out file format: ELF 64-bit, x86-64 
 
0000000000001129 <main>:
1129: f3 0f 1e fa endbr64
112d: 55 push %rbp
112e: 48 89 e5 mov %rsp,%rbp
1131: c7 45 f8 00 00 00 00 movl $0x0,-0x8(%rbp)
1138: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp)
113f: eb 0a jmp 114b <main+0x22>
1141: 8b 45 fc mov -0x4(%rbp),%eax
1144: 01 45 f8 add %eax,-0x8(%rbp)
1147: 83 45 fc 01 addl $0x1,-0x4(%rbp)
114b: 81 7d fc 0f 27 00 00 cmpl $0x270f,-0x4(%rbp)
1152: 7e ed jle 1141 <main+0x18>
1154: 90 nop
1155: 90 nop
1156: 5d pop %rbp
1157: c3 retq
1158: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1)
115f: 00  

ARM: 
a.out file format: ELF 64-bit, ARM 

000000000000071c <main>:
71c: d10043ff sub sp, sp, #0x10
720: b9000bff str wzr, [sp, #8]
724: b9000fff str wzr, [sp, #12]
728: 14000008 b 748 <main+0x2c>
72c: b9400be1 ldr w1, [sp, #8]
730: b9400fe0 ldr w0, [sp, #12]
734: 0b000020 add w0, w1, w0
738: b9000be0 str w0, [sp, #8]
73c: b9400fe0 ldr w0, [sp, #12]
740: 11000400 add w0, w0, #0x1
744: b9000fe0 str w0, [sp, #12]

 

 
 

748: b9400fe1 ldr w1, [sp, #12]


74c: 5284e1e0 mov w0, #0x270f // #9999
750: 6b00003f cmp w1, w0
754: 54fffecd b.le 72c <main+0x10>
758: d503201f nop
75c: d503201f nop
760: 910043ff add sp, sp, #0x10
764: d65f03c0 ret  

Question 6 
Microarchitecture of machine’s processor: s​ kylake 

Question 7 
The following test.c file was used: 

#include ​<stdio.h>
void​ main()
{
int​ sum = ​0​;
for​(​int​ i = ​0​ ; i < ​100000000​ ; ++i)
{
sum = sum + i;
}

 

test.c was compiled using the following 2 options: 

gcc -march=native -o test-march test.c  


 
gcc -o test-raw test.c  

Running test-raw and test-march, it was found that they had comparable compilation and 
execution time. This is because the performance boost by optimisation through the march 
option is insignificant for small programs. This option can be useful for compiling code to 
run on IoT devices. 

 

Potrebbero piacerti anche