Simplify string type to just contain a length

This commit is contained in:
Sameer Rahmani 2022-06-02 17:32:59 +01:00
parent d64910e9cc
commit ea403d444d
3 changed files with 5 additions and 7 deletions

View File

@ -126,6 +126,9 @@ functions and detect hot functions similar to how javascript jits do it
and recompile those functions with more optimization passes
* TODOs
** Strings
*** TODO How to concat to strings in a functional and immutable way?
Should we include an pointer to another string???
** TODO Create =Catch2= generators to be used in tests. Specially for the =reader= tests
** TODO Investigate possible implementanion for Internal Errors
- An option is to use llvm registry functionality like the one used in =clang-doc= instead of

View File

@ -24,7 +24,6 @@ class Serene_Type<string name> : TypeDef<Serene_Dialect, name> { }
def SereneString : Serene_Type<"String"> {
let mnemonic = "string";
let summary = "A simple string type";
let description = [{
@ -32,8 +31,6 @@ def SereneString : Serene_Type<"String"> {
i8*: buffer; pointer to the character buffer
i32: length; the number of chars in the buffer
i32: maxlen; the maximum number of chars in the buffer
i32: factor; the number of chars to preallocate when growing
}];
}

View File

@ -29,14 +29,12 @@ mlir::Type getStringTypeinLLVM(mlir::MLIRContext &ctx) {
auto stringStruct =
ll::LLVMStructType::getIdentified(&ctx, "serene.core.string");
mlir::SmallVector<mlir::Type, 2> subtypes;
mlir::SmallVector<mlir::Type, 4> subtypes;
subtypes.push_back(
ll::LLVMPointerType::get(mlir::IntegerType::get(&ctx, I8_SIZE)));
// Length field
subtypes.push_back(mlir::IntegerType::get(&ctx, I32_SIZE));
// subtypes.push_back(mlir::IntegerType::get(&ctx, I32_SIZE));
// subtypes.push_back(mlir::IntegerType::get(&ctx, I32_SIZE));
(void)stringStruct.setBody(subtypes, false);
return stringStruct;