How can I implement a string data type in LLVM?

后端 未结 5 1843
眼角桃花
眼角桃花 2021-01-31 10:31

I have been looking at LLVM lately, and I find it to be quite an interesting architecture. However, looking through the tutorial and the reference material, I can\'t see any ex

5条回答
  •  鱼传尺愫
    2021-01-31 11:05

    Think about how a string is represented in common languages:

    • C: a pointer to a character. You don't have to do anything special.
    • C++: string is a complex object with a constructor, destructor, and copy constructor. On the inside, it usually holds essentially a C string.
    • Java/C#/...: a string is a complex object holding an array of characters.

    LLVM's name is very self explanatory. It really is "low level". You have to implement strings how ever you want them to be. It would be silly for LLVM to force anyone into a specific implementation.

提交回复
热议问题