3 ms·
One of the criticisms I have heard of C-- is that it doesn't distinguish between integer and floating-point data in the type system. There are some architecture
by TazeTSchnitzel 4y ago
One of the criticisms I have heard of C-- is that it doesn't distinguish between integer and floating-point data in the type system. There are some architectures where that wouldn't be a problem, but most modern CPUs have completely separate integer and floating-point data paths, with a performance penalty for shuffling data between them. Generating good code on these systems from C-- source requires more effort than it should.
- mgaunard 4y agoModern architectures have different register banks for the two, but that's irrelevant, C-- is not register-centric.
- noobermin 4y agoIsn't the point of C-- to be an IR, easily compileable to assembly on the target?
- chrisseaton 4y agoNo the other way around - easily emittable, letting the backend in turn do the heavy lifting to lower it.
- TazeTSchnitzel 4y agoThe backend can of course try to guess what type of register data should live in, but it's not always going to make the right decisions if it doesn't have type information to work with.
- mgaunard 4y agoType information is not what conveys that information, it's the operations used on the data that matters.
- roelschroeven 4y agoThey have a reason for doing things that way, which they state in the specification (in the PDF at https://www.cs.tufts.edu/~nr/c--/extern/man2.pdf https://www.cs.tufts.edu/~nr/c--/extern/man2.pdf it's in figure 2 on page 10). I'm not knowledgeable enough in compilers and computer architecture to decide if it's a good reason. As far as I understand it, their reasoning is that implementations can easily enough figure out how the data is used to decide in which registers to put the data; distinguishing between integers and floats in the type system would be too restrictive, since they want to support architectures with more types of registers than the classic two.