Skip to content

Instantly share code, notes, and snippets.

View anoopsarkar's full-sized avatar
💭
slow train coming ...

Anoop Sarkar anoopsarkar

💭
slow train coming ...
View GitHub Profile
@anoopsarkar
anoopsarkar / quicksort.ll
Created November 20, 2021 17:33
decafcomp LLVM output for quicksort.decaf with main returning int
; ModuleID = 'QuickSort'
source_filename = "DecafComp"
@list = global [100 x i32] zeroinitializer
@globalstring = private unnamed_addr constant [2 x i8] c"\0A\00", align 1
@globalstring.1 = private unnamed_addr constant [7 x i8] c"List:\0A\00", align 1
@globalstring.2 = private unnamed_addr constant [2 x i8] c" \00", align 1
@globalstring.3 = private unnamed_addr constant [16 x i8] c"After sorting:\0A\00", align 1
declare void @print_string(i8*)
@anoopsarkar
anoopsarkar / cmpt_379_compiler_contest_zip_contents.txt
Created December 7, 2020 17:26
Example of what "unzip -l contest.zip" should look like for the CMPT 379 Compiler Contest Fall 2020
Archive: contest.zip
Length Date Time Name
--------- ---------- ----- ----
0 12-07-2020 09:23 references/anoop/
4 11-25-2020 09:15 references/anoop/emptymethod.out
0 11-25-2020 09:15 references/anoop/ok-scoping-2.out
4 11-25-2020 09:15 references/anoop/and.out
10 11-25-2020 09:15 references/anoop/fshadow.out
3 11-25-2020 09:15 references/anoop/gr.out
4 11-25-2020 09:15 references/anoop/forward3.out
%{
#include "exprdefs.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Verifier.h"
#include "llvm/IR/IRBuilder.h"
#include <cstdio>
#include <stdexcept>
@anoopsarkar
anoopsarkar / symtbl_test.cc
Last active May 21, 2019 16:00
Symbol table in C++11
// g++ -std=c++17 -o symtbl_test symtbl_test.c
#include <utility> // std::pair, std::make_pair
#include <string> // std::string
#include <iostream> // std::cout
#include <map> // std::map
#include <list> // std::list
using namespace std;
typedef pair<int, int> descriptor;
@anoopsarkar
anoopsarkar / intarr_start.c
Created June 20, 2018 02:07
Starting code for CMPT 127 Lab 5 Su2018
#include <stdio.h>
#include <stdlib.h>
#include "intarr.h"
intarr_t* intarr_create( unsigned int len )
{
return NULL;
}
void intarr_destroy( intarr_t* ia )
@anoopsarkar
anoopsarkar / intarr.h
Created June 19, 2018 03:29
CMPT 127 Lab 5 Tasks
/*
* intarr.h
*
* Provides a bounds-checked, resizable array of integers with
* random-access and stack interfaces, and several utility functions
* that operate on them.
*
*/
/* DO NOT CHANGE THIS FILE - YOUR CODE WILL BE COMPILED AGAINST THE
@anoopsarkar
anoopsarkar / imgops.c
Created June 19, 2018 03:26
CMPT 127 Lab 3 Tasks
/*
* imageops.c - Simple operations on images
*
* C laboratory exercises.
* Richard Vaughan, 2014.
*/
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
@anoopsarkar
anoopsarkar / ptbpos2uni.py
Created June 15, 2017 22:58 — forked from nschneid/ptbpos2uni.py
Given a new-style Penn Treebank English tree, produce the part-of-speech tags according to the Universal Dependencies project.
#!/usr/bin/env python2.7
'''
Converts new-style PTB POS tags to the English tagset from the Universal Dependencies project
(see universal-pos-en.html, from http://universaldependencies.github.io/docs/en/pos/all.html).
There are 17 such tags, expanded from the original 12 Universal POS tags of Petrov et al. 2011.
See "limitations" comment below for some details on our interpretation of the difficult-to-map
categories.
In new-style PTB, TO only applies to prepositional (not infinitival) "to".
@anoopsarkar
anoopsarkar / realloc_demo.c
Created June 13, 2017 06:15
realloc demo
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
int main( void )
{
char h[] = "hello";
char w[] = "this is a very long string .";
char* x = malloc( strlen(h)*sizeof(char) );
@anoopsarkar
anoopsarkar / lab5_lab1_t2_pointer.c
Created June 13, 2017 06:14
Print out the size of a pointer and the pointer address
#include <stdlib.h>
#include <limits.h>
#include <stdio.h>
int main( void )
{
char x[] = {1,2,3,4,5};
int* y = malloc( sizeof(int) );
printf("sz int*=%lu\nsz char*=%lu\nsz double*=%lu\nsz x=%lu\nsz y=%lu\nsz &x=%lu\n&x=%p\ny=%p\n",
sizeof(int*),