Compiler - front end back endLearning to write a compilerWhat does a just-in-time (JIT) compiler do?Separating backend and front endOOAD book recommendation: from theory to practiceC++ compilers and back/front endsHow do I achieve the theoretical maximum of 4 FLOPs per cycle?Best way to secure javascript front end/REST back end architecture web site?Why compilers are written in C/C++ instead of using CoffeeScript (JavaScript, Node JS)?Dilemma: when to use Fragments vs Activities:
Does the Pi 4 resolve the Ethernet+USB bottleneck issue of past versions?
What is the difference between x RadToDeg cos x div and COSC?
Are metaheuristics ever practical for continuous optimization?
Can I travel from Germany to England alone as an unaccompanied minor?
Does “comme on était à New York” mean “since” or “as though”?
In native German words, is Q always followed by U, as in English?
How can my story take place on Earth without referring to our existing cities and countries?
What is "oversubscription" in Networking?
Can a police officer film me on their personal device in my own home?
3D nonogram, beginner's edition
Can a single server be associated with multiple domains?
Meaning of もてり and use of が
Questions about authorship rank and academic politics
Why did this meteor appear cyan?
Automatically convert a number to use the correct SI unit prefix
How was film developed in the late 1920s?
Reverse of diffraction
Is there a way for presidents to legally extend their terms beyond the maximum of four years?
Why isn’t the tax system continuous rather than bracketed?
Can a US President have someone sent to prison?
How can I convince my reader that I will not use a certain trope?
How to fix a dry solder pin in BGA package?
How can I reduce the sound of rain on a range hood vent?
I hit a pipe with a mower and now it won't turn
Compiler - front end back end
Learning to write a compilerWhat does a just-in-time (JIT) compiler do?Separating backend and front endOOAD book recommendation: from theory to practiceC++ compilers and back/front endsHow do I achieve the theoretical maximum of 4 FLOPs per cycle?Best way to secure javascript front end/REST back end architecture web site?Why compilers are written in C/C++ instead of using CoffeeScript (JavaScript, Node JS)?Dilemma: when to use Fragments vs Activities:
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I understand the structure of a compiler in regards to front-end and back-end. However, I am not sure why compilers are often divided into front-end and back-end. I am sure there are many reasons can you give me a few? because, most books / websites tell you what they are but fail to tell you why!
Thank you.
architecture compiler-construction
add a comment |
I understand the structure of a compiler in regards to front-end and back-end. However, I am not sure why compilers are often divided into front-end and back-end. I am sure there are many reasons can you give me a few? because, most books / websites tell you what they are but fail to tell you why!
Thank you.
architecture compiler-construction
add a comment |
I understand the structure of a compiler in regards to front-end and back-end. However, I am not sure why compilers are often divided into front-end and back-end. I am sure there are many reasons can you give me a few? because, most books / websites tell you what they are but fail to tell you why!
Thank you.
architecture compiler-construction
I understand the structure of a compiler in regards to front-end and back-end. However, I am not sure why compilers are often divided into front-end and back-end. I am sure there are many reasons can you give me a few? because, most books / websites tell you what they are but fail to tell you why!
Thank you.
architecture compiler-construction
architecture compiler-construction
edited Mar 19 '12 at 5:30
Andrew Cooper
29k3 gold badges65 silver badges106 bronze badges
29k3 gold badges65 silver badges106 bronze badges
asked Mar 19 '12 at 5:27
user249375
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
The front-end deals with the language itself: scanning, parsing, the parse-tree. The back end deals with the target system: object code formats, the machine code itself, ... The two things don't have all that much to do with each other, and for a portable compiler it is highly desirable to use the same front-end with multiple backends, one per target.
You can take that further, as gcc
does, and have a front/backend interface that is language-independent, so you can use different language front-ends with the same backend. In the old days this was called the MxN problem: you don't want to have to write MxN compilers where you have M languages and N target systems. The idea is to only have to write M+N compilers.
Can you please tell me how is it M + N compilers ? I think we have M front ends to convert to ICG and N code generators to convert to Target machine code. Are you considering each front end and back end as a compiler ?
– Zephyr
Dec 3 '17 at 17:38
1
@Zephyr, Without a FE/BE combination we would need so many permutations which is unnecessary/unwieldy.
– Paul Joseph
Dec 14 '17 at 20:10
@Zephyr Yes, a front end/back end combination is a compiler. Surely this is obvious?
– user207421
Feb 19 '18 at 3:48
add a comment |
If you're talking about the front-end being the parser which tokenises the source code, and back-end being the bit which generates executable code based on the tokenised code, then one very good reason is this: portability.
Separating the parser from the executable code generation makes it much easier to port a compiler from one processor architecture to another.
add a comment |
Because you want to use some sort of internal pseudo code or tables/data structures. For example if you have some line of code:
a = b + c;
You would want to take that and break it into an intermediate language or IR (Intermediate representation):
load b
load c
add b + c
store a
as an example -- there are many solutions. The intermediate language is better than going straight to assembly for a particular target for a number of reasons:
- By abstracting the hardware and providing a "logical number" of registers we are independent of the final "physical number" of registers and hardware layout. For example, the native
ADD
instruction may be stack based, take 1-operand, take 2-operands, or even 3 operands. At this higher level we don't need to know, or care, about the lower level hardware implementation. - The internal language can be optimized if you have an optimizer, and
- Is generic enough to be used on multiple targets if you have a wish to target different processors.
I dont know enough about it but I think you also have the common used parsers bison/flex, boil you down into some sort of intermediate code/instruction set and then you write a backend for that.
You also benefit that you can for example have a C and C++ and other language front end, without affecting the backend.
You also benefit from breaking the compiler into logical modules blocks, you can develop and test the front end independently from the back end. llvm for example, allows for the export and import of the intermediate language, you could if you really really wanted to write code using the intermediate language and have the benefit of multiple targets on the backend.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9765414%2fcompiler-front-end-back-end%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
The front-end deals with the language itself: scanning, parsing, the parse-tree. The back end deals with the target system: object code formats, the machine code itself, ... The two things don't have all that much to do with each other, and for a portable compiler it is highly desirable to use the same front-end with multiple backends, one per target.
You can take that further, as gcc
does, and have a front/backend interface that is language-independent, so you can use different language front-ends with the same backend. In the old days this was called the MxN problem: you don't want to have to write MxN compilers where you have M languages and N target systems. The idea is to only have to write M+N compilers.
Can you please tell me how is it M + N compilers ? I think we have M front ends to convert to ICG and N code generators to convert to Target machine code. Are you considering each front end and back end as a compiler ?
– Zephyr
Dec 3 '17 at 17:38
1
@Zephyr, Without a FE/BE combination we would need so many permutations which is unnecessary/unwieldy.
– Paul Joseph
Dec 14 '17 at 20:10
@Zephyr Yes, a front end/back end combination is a compiler. Surely this is obvious?
– user207421
Feb 19 '18 at 3:48
add a comment |
The front-end deals with the language itself: scanning, parsing, the parse-tree. The back end deals with the target system: object code formats, the machine code itself, ... The two things don't have all that much to do with each other, and for a portable compiler it is highly desirable to use the same front-end with multiple backends, one per target.
You can take that further, as gcc
does, and have a front/backend interface that is language-independent, so you can use different language front-ends with the same backend. In the old days this was called the MxN problem: you don't want to have to write MxN compilers where you have M languages and N target systems. The idea is to only have to write M+N compilers.
Can you please tell me how is it M + N compilers ? I think we have M front ends to convert to ICG and N code generators to convert to Target machine code. Are you considering each front end and back end as a compiler ?
– Zephyr
Dec 3 '17 at 17:38
1
@Zephyr, Without a FE/BE combination we would need so many permutations which is unnecessary/unwieldy.
– Paul Joseph
Dec 14 '17 at 20:10
@Zephyr Yes, a front end/back end combination is a compiler. Surely this is obvious?
– user207421
Feb 19 '18 at 3:48
add a comment |
The front-end deals with the language itself: scanning, parsing, the parse-tree. The back end deals with the target system: object code formats, the machine code itself, ... The two things don't have all that much to do with each other, and for a portable compiler it is highly desirable to use the same front-end with multiple backends, one per target.
You can take that further, as gcc
does, and have a front/backend interface that is language-independent, so you can use different language front-ends with the same backend. In the old days this was called the MxN problem: you don't want to have to write MxN compilers where you have M languages and N target systems. The idea is to only have to write M+N compilers.
The front-end deals with the language itself: scanning, parsing, the parse-tree. The back end deals with the target system: object code formats, the machine code itself, ... The two things don't have all that much to do with each other, and for a portable compiler it is highly desirable to use the same front-end with multiple backends, one per target.
You can take that further, as gcc
does, and have a front/backend interface that is language-independent, so you can use different language front-ends with the same backend. In the old days this was called the MxN problem: you don't want to have to write MxN compilers where you have M languages and N target systems. The idea is to only have to write M+N compilers.
edited Mar 19 '12 at 15:16
Robert Harvey♦
151k36 gold badges289 silver badges426 bronze badges
151k36 gold badges289 silver badges426 bronze badges
answered Mar 19 '12 at 5:34
user207421user207421
267k26 gold badges221 silver badges374 bronze badges
267k26 gold badges221 silver badges374 bronze badges
Can you please tell me how is it M + N compilers ? I think we have M front ends to convert to ICG and N code generators to convert to Target machine code. Are you considering each front end and back end as a compiler ?
– Zephyr
Dec 3 '17 at 17:38
1
@Zephyr, Without a FE/BE combination we would need so many permutations which is unnecessary/unwieldy.
– Paul Joseph
Dec 14 '17 at 20:10
@Zephyr Yes, a front end/back end combination is a compiler. Surely this is obvious?
– user207421
Feb 19 '18 at 3:48
add a comment |
Can you please tell me how is it M + N compilers ? I think we have M front ends to convert to ICG and N code generators to convert to Target machine code. Are you considering each front end and back end as a compiler ?
– Zephyr
Dec 3 '17 at 17:38
1
@Zephyr, Without a FE/BE combination we would need so many permutations which is unnecessary/unwieldy.
– Paul Joseph
Dec 14 '17 at 20:10
@Zephyr Yes, a front end/back end combination is a compiler. Surely this is obvious?
– user207421
Feb 19 '18 at 3:48
Can you please tell me how is it M + N compilers ? I think we have M front ends to convert to ICG and N code generators to convert to Target machine code. Are you considering each front end and back end as a compiler ?
– Zephyr
Dec 3 '17 at 17:38
Can you please tell me how is it M + N compilers ? I think we have M front ends to convert to ICG and N code generators to convert to Target machine code. Are you considering each front end and back end as a compiler ?
– Zephyr
Dec 3 '17 at 17:38
1
1
@Zephyr, Without a FE/BE combination we would need so many permutations which is unnecessary/unwieldy.
– Paul Joseph
Dec 14 '17 at 20:10
@Zephyr, Without a FE/BE combination we would need so many permutations which is unnecessary/unwieldy.
– Paul Joseph
Dec 14 '17 at 20:10
@Zephyr Yes, a front end/back end combination is a compiler. Surely this is obvious?
– user207421
Feb 19 '18 at 3:48
@Zephyr Yes, a front end/back end combination is a compiler. Surely this is obvious?
– user207421
Feb 19 '18 at 3:48
add a comment |
If you're talking about the front-end being the parser which tokenises the source code, and back-end being the bit which generates executable code based on the tokenised code, then one very good reason is this: portability.
Separating the parser from the executable code generation makes it much easier to port a compiler from one processor architecture to another.
add a comment |
If you're talking about the front-end being the parser which tokenises the source code, and back-end being the bit which generates executable code based on the tokenised code, then one very good reason is this: portability.
Separating the parser from the executable code generation makes it much easier to port a compiler from one processor architecture to another.
add a comment |
If you're talking about the front-end being the parser which tokenises the source code, and back-end being the bit which generates executable code based on the tokenised code, then one very good reason is this: portability.
Separating the parser from the executable code generation makes it much easier to port a compiler from one processor architecture to another.
If you're talking about the front-end being the parser which tokenises the source code, and back-end being the bit which generates executable code based on the tokenised code, then one very good reason is this: portability.
Separating the parser from the executable code generation makes it much easier to port a compiler from one processor architecture to another.
edited Mar 25 at 12:26
Fabian Lauer
3,3182 gold badges16 silver badges25 bronze badges
3,3182 gold badges16 silver badges25 bronze badges
answered Mar 19 '12 at 5:33
Andrew CooperAndrew Cooper
29k3 gold badges65 silver badges106 bronze badges
29k3 gold badges65 silver badges106 bronze badges
add a comment |
add a comment |
Because you want to use some sort of internal pseudo code or tables/data structures. For example if you have some line of code:
a = b + c;
You would want to take that and break it into an intermediate language or IR (Intermediate representation):
load b
load c
add b + c
store a
as an example -- there are many solutions. The intermediate language is better than going straight to assembly for a particular target for a number of reasons:
- By abstracting the hardware and providing a "logical number" of registers we are independent of the final "physical number" of registers and hardware layout. For example, the native
ADD
instruction may be stack based, take 1-operand, take 2-operands, or even 3 operands. At this higher level we don't need to know, or care, about the lower level hardware implementation. - The internal language can be optimized if you have an optimizer, and
- Is generic enough to be used on multiple targets if you have a wish to target different processors.
I dont know enough about it but I think you also have the common used parsers bison/flex, boil you down into some sort of intermediate code/instruction set and then you write a backend for that.
You also benefit that you can for example have a C and C++ and other language front end, without affecting the backend.
You also benefit from breaking the compiler into logical modules blocks, you can develop and test the front end independently from the back end. llvm for example, allows for the export and import of the intermediate language, you could if you really really wanted to write code using the intermediate language and have the benefit of multiple targets on the backend.
add a comment |
Because you want to use some sort of internal pseudo code or tables/data structures. For example if you have some line of code:
a = b + c;
You would want to take that and break it into an intermediate language or IR (Intermediate representation):
load b
load c
add b + c
store a
as an example -- there are many solutions. The intermediate language is better than going straight to assembly for a particular target for a number of reasons:
- By abstracting the hardware and providing a "logical number" of registers we are independent of the final "physical number" of registers and hardware layout. For example, the native
ADD
instruction may be stack based, take 1-operand, take 2-operands, or even 3 operands. At this higher level we don't need to know, or care, about the lower level hardware implementation. - The internal language can be optimized if you have an optimizer, and
- Is generic enough to be used on multiple targets if you have a wish to target different processors.
I dont know enough about it but I think you also have the common used parsers bison/flex, boil you down into some sort of intermediate code/instruction set and then you write a backend for that.
You also benefit that you can for example have a C and C++ and other language front end, without affecting the backend.
You also benefit from breaking the compiler into logical modules blocks, you can develop and test the front end independently from the back end. llvm for example, allows for the export and import of the intermediate language, you could if you really really wanted to write code using the intermediate language and have the benefit of multiple targets on the backend.
add a comment |
Because you want to use some sort of internal pseudo code or tables/data structures. For example if you have some line of code:
a = b + c;
You would want to take that and break it into an intermediate language or IR (Intermediate representation):
load b
load c
add b + c
store a
as an example -- there are many solutions. The intermediate language is better than going straight to assembly for a particular target for a number of reasons:
- By abstracting the hardware and providing a "logical number" of registers we are independent of the final "physical number" of registers and hardware layout. For example, the native
ADD
instruction may be stack based, take 1-operand, take 2-operands, or even 3 operands. At this higher level we don't need to know, or care, about the lower level hardware implementation. - The internal language can be optimized if you have an optimizer, and
- Is generic enough to be used on multiple targets if you have a wish to target different processors.
I dont know enough about it but I think you also have the common used parsers bison/flex, boil you down into some sort of intermediate code/instruction set and then you write a backend for that.
You also benefit that you can for example have a C and C++ and other language front end, without affecting the backend.
You also benefit from breaking the compiler into logical modules blocks, you can develop and test the front end independently from the back end. llvm for example, allows for the export and import of the intermediate language, you could if you really really wanted to write code using the intermediate language and have the benefit of multiple targets on the backend.
Because you want to use some sort of internal pseudo code or tables/data structures. For example if you have some line of code:
a = b + c;
You would want to take that and break it into an intermediate language or IR (Intermediate representation):
load b
load c
add b + c
store a
as an example -- there are many solutions. The intermediate language is better than going straight to assembly for a particular target for a number of reasons:
- By abstracting the hardware and providing a "logical number" of registers we are independent of the final "physical number" of registers and hardware layout. For example, the native
ADD
instruction may be stack based, take 1-operand, take 2-operands, or even 3 operands. At this higher level we don't need to know, or care, about the lower level hardware implementation. - The internal language can be optimized if you have an optimizer, and
- Is generic enough to be used on multiple targets if you have a wish to target different processors.
I dont know enough about it but I think you also have the common used parsers bison/flex, boil you down into some sort of intermediate code/instruction set and then you write a backend for that.
You also benefit that you can for example have a C and C++ and other language front end, without affecting the backend.
You also benefit from breaking the compiler into logical modules blocks, you can develop and test the front end independently from the back end. llvm for example, allows for the export and import of the intermediate language, you could if you really really wanted to write code using the intermediate language and have the benefit of multiple targets on the backend.
edited Mar 24 '18 at 12:54
Michaelangel007
1,80317 silver badges20 bronze badges
1,80317 silver badges20 bronze badges
answered Mar 19 '12 at 5:40
old_timerold_timer
50.2k7 gold badges64 silver badges126 bronze badges
50.2k7 gold badges64 silver badges126 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9765414%2fcompiler-front-end-back-end%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown